Skip to content

Commit 86e3fd6

Browse files
authored
Cleanup GHC macros (because min version is 8.8.4) (#3281)
* Drop min_version_ghc (8.8.4 is min supported) * Drop conditional glasgow_haskell cpp * Inline some imports (review feedback) * Drop hie-compat 8.6 (review feedback) * Dropping more ghc 8.6 related code and docs * Eval: Include tests that were broken for 8.6
1 parent 9b491f7 commit 86e3fd6

File tree

32 files changed

+40
-3497
lines changed

32 files changed

+40
-3497
lines changed

docs/contributing/contributing.md

-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ To create binaries:
6464
* `nix build .#haskell-language-server-884` - GHC 8.8.4
6565
* `nix build .#haskell-language-server-901` - GHC 9.0.1
6666

67-
GHC 8.6.5 is not supported here because `nixpkgs-unstable` no longer maintains the corresponding packages set.
68-
6967
## Testing
7068

7169
The tests make use of the [Tasty](https://github.com/feuerbach/tasty) test framework.

docs/contributing/plugin-tutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ And here is the gist of the algorithm:
3434

3535
## Setup
3636

37-
To get started, let’s fetch the HLS repo and build it. You need at least GHC 8.6 for this:
37+
To get started, let’s fetch the HLS repo and build it. You need at least GHC 8.8 for this:
3838

3939
```
4040
git clone --recursive http://github.com/haskell/haskell-language-server hls

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Homebrew users can install `haskell-language-server` using the following command
157157
brew install haskell-language-server
158158
```
159159

160-
This formula contains HLS binaries compiled with GHC versions available via Homebrew; at the moment those are: 8.6.5, 8.8.4, 8.10.7.
160+
This formula contains HLS binaries compiled with GHC versions available via Homebrew; at the moment those are: 8.8.4, 8.10.7.
161161

162162
You need to provide your own GHC/Cabal/Stack as required by your project, possibly via Homebrew.
163163

ghcide-bench/ghcide-bench.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ synopsis: An LSP client for running performance experiments on HLS
1212
description: An LSP client for running performance experiments on HLS
1313
homepage: https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme
1414
bug-reports: https://github.com/haskell/haskell-language-server/issues
15-
tested-with: GHC == 8.6.5 || == 8.8.4 || == 8.10.7 || == 9.0.2 || == 9.2.3 || == 9.2.4
15+
tested-with: GHC == 8.8.4 || == 8.10.7 || == 9.0.2 || == 9.2.3 || == 9.2.4
1616

1717
source-repository head
1818
type: git

ghcide/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ If you can't get `ghcide` working outside the editor, see [this setup troublesho
9898

9999
### Optimal project setup
100100

101-
`ghcide` has been designed to handle projects with hundreds or thousands of modules. If `ghci` can handle it, then `ghcide` should be able to handle it. The only caveat is that this currently requires GHC >= 8.6, and that the first time a module is loaded in the editor will trigger generation of support files in the background if those do not already exist.
101+
`ghcide` has been designed to handle projects with hundreds or thousands of modules. If `ghci` can handle it, then `ghcide` should be able to handle it. The only caveat is that this currently requires GHC >= 8.8, and that the first time a module is loaded in the editor will trigger generation of support files in the background if those do not already exist.
102102

103103
### Using with VS Code
104104

ghcide/ghcide.cabal

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ library
9999
unliftio-core,
100100
ghc-boot-th,
101101
ghc-boot,
102-
ghc >= 8.6,
102+
ghc >= 8.8,
103103
ghc-check >=0.5.0.8,
104104
ghc-paths,
105105
cryptohash-sha1 >=0.11.100 && <0.12,
@@ -363,7 +363,7 @@ test-suite ghcide-tests
363363
text,
364364
text-rope,
365365
unordered-containers,
366-
if (impl(ghc >= 8.6) && impl(ghc < 9.2))
366+
if impl(ghc < 9.2)
367367
build-depends:
368368
record-dot-preprocessor,
369369
record-hasfield

ghcide/src/Development/IDE/Core/Compile.hs

-2
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,7 @@ getModSummaryFromImports env fp modTime contents = do
11811181
msrModSummary =
11821182
ModSummary
11831183
{ ms_mod = modl
1184-
#if MIN_VERSION_ghc(8,8,0)
11851184
, ms_hie_date = Nothing
1186-
#endif
11871185
#if MIN_VERSION_ghc(9,3,0)
11881186
, ms_dyn_obj_date = Nothing
11891187
, ms_ghc_prim_import = ghc_prim_import

ghcide/src/Development/IDE/Core/Rules.hs

-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ module Development.IDE.Core.Rules(
6262
DisplayTHWarning(..),
6363
) where
6464

65-
#if !MIN_VERSION_ghc(8,8,0)
66-
import Control.Applicative (liftA2)
67-
#endif
6865
import Control.Concurrent.Async (concurrently)
6966
import Control.Concurrent.Strict
7067
import Control.DeepSeq

ghcide/src/Development/IDE/Core/Tracing.hs

+4-12
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,16 @@ import OpenTelemetry.Eventlog (SpanInFlight (..), addEvent,
3737
beginSpan, endSpan, setTag,
3838
withSpan)
3939

40-
#if MIN_VERSION_ghc(8,8,0)
41-
otTracedProvider :: MonadUnliftIO m => PluginId -> ByteString -> m a -> m a
42-
otTracedGarbageCollection :: (MonadMask f, MonadIO f, Show a) => ByteString -> f [a] -> f [a]
43-
withEventTrace :: (MonadMask m, MonadIO m) => String -> ((ByteString -> m ()) -> m a) -> m a
44-
#else
45-
otTracedProvider :: MonadUnliftIO m => PluginId -> String -> m a -> m a
46-
otTracedGarbageCollection :: (MonadMask f, MonadIO f, Show a) => String -> f [a] -> f [a]
47-
withEventTrace :: (MonadMask m, MonadIO m) => String -> ((ByteString -> m ()) -> m a) -> m a
48-
#endif
4940

50-
withTrace :: (MonadMask m, MonadIO m) =>
51-
String -> ((String -> String -> m ()) -> m a) -> m a
41+
withTrace :: (MonadMask m, MonadIO m) => String -> ((String -> String -> m ()) -> m a) -> m a
5242
withTrace name act
5343
| userTracingEnabled
5444
= withSpan (fromString name) $ \sp -> do
5545
let setSpan' k v = setTag sp (fromString k) (fromString v)
5646
act setSpan'
5747
| otherwise = act (\_ _ -> pure ())
5848

49+
withEventTrace :: (MonadMask m, MonadIO m) => String -> ((ByteString -> m ()) -> m a) -> m a
5950
withEventTrace name act
6051
| userTracingEnabled
6152
= withSpan (fromString name) $ \sp -> do
@@ -125,6 +116,7 @@ otTracedAction key file mode result act
125116
(\sp -> act (liftIO . setTag sp "diagnostics" . encodeUtf8 . showDiagnostics ))
126117
| otherwise = act (\_ -> return ())
127118

119+
otTracedGarbageCollection :: (MonadMask f, MonadIO f, Show a) => ByteString -> f [a] -> f [a]
128120
otTracedGarbageCollection label act
129121
| userTracingEnabled = fst <$>
130122
generalBracket
@@ -138,6 +130,7 @@ otTracedGarbageCollection label act
138130
(const act)
139131
| otherwise = act
140132

133+
otTracedProvider :: MonadUnliftIO m => PluginId -> ByteString -> m a -> m a
141134
otTracedProvider (PluginId pluginName) provider act
142135
| userTracingEnabled = do
143136
runInIO <- askRunInIO
@@ -146,4 +139,3 @@ otTracedProvider (PluginId pluginName) provider act
146139
runInIO act
147140
| otherwise = act
148141

149-

ghcide/src/Development/IDE/GHC/Compat.hs

+3-46
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,8 @@ import DynFlags hiding (ExposePackage)
228228
import HscTypes
229229
import MkIface hiding (writeIfaceFile)
230230

231-
#if MIN_VERSION_ghc(8,8,0)
232231
import StringBuffer (hPutStringBuffer)
233-
#endif
234232
import qualified SysTools
235-
236-
#if !MIN_VERSION_ghc(8,8,0)
237-
import qualified EnumSet
238-
import SrcLoc (RealLocated)
239-
240-
import Foreign.ForeignPtr
241-
import System.IO
242-
#endif
243233
#endif
244234

245235
import Compat.HieAst (enrichHie)
@@ -385,13 +375,6 @@ corePrepExpr _ = GHC.corePrepExpr
385375
simplifyExpr df _ = GHC.simplifyExpr df
386376
#endif
387377

388-
#if !MIN_VERSION_ghc(8,8,0)
389-
hPutStringBuffer :: Handle -> StringBuffer -> IO ()
390-
hPutStringBuffer hdl (StringBuffer buf len cur)
391-
= withForeignPtr (plusForeignPtr buf cur) $ \ptr ->
392-
hPutBuf hdl ptr len
393-
#endif
394-
395378
#if MIN_VERSION_ghc(9,2,0)
396379
type ErrMsg = MsgEnvelope DecoratedSDoc
397380
#endif
@@ -445,12 +428,7 @@ hieExportNames = nameListFromAvails . hie_exports
445428
type NameCacheUpdater = NameCache
446429
#else
447430
upNameCache :: IORef NameCache -> (NameCache -> (NameCache, c)) -> IO c
448-
#if MIN_VERSION_ghc(8,8,0)
449431
upNameCache = updNameCache
450-
#else
451-
upNameCache ref upd_fn
452-
= atomicModifyIORef' ref upd_fn
453-
#endif
454432
#endif
455433

456434
#if !MIN_VERSION_ghc(9,0,1)
@@ -480,27 +458,15 @@ addIncludePathsQuote path x = x{includePaths = f $ includePaths x}
480458
where f i = i{includePathsQuote = path : includePathsQuote i}
481459

482460
setHieDir :: FilePath -> DynFlags -> DynFlags
483-
setHieDir _f d =
484-
#if MIN_VERSION_ghc(8,8,0)
485-
d { hieDir = Just _f}
486-
#else
487-
d
488-
#endif
461+
setHieDir _f d = d { hieDir = Just _f}
489462

490463
dontWriteHieFiles :: DynFlags -> DynFlags
491-
dontWriteHieFiles d =
492-
#if MIN_VERSION_ghc(8,8,0)
493-
gopt_unset d Opt_WriteHie
494-
#else
495-
d
496-
#endif
464+
dontWriteHieFiles d = gopt_unset d Opt_WriteHie
497465

498466
setUpTypedHoles ::DynFlags -> DynFlags
499467
setUpTypedHoles df
500468
= flip gopt_unset Opt_AbstractRefHoleFits -- too spammy
501-
#if MIN_VERSION_ghc(8,8,0)
502469
$ flip gopt_unset Opt_ShowDocsOfHoleFits -- not used
503-
#endif
504470
$ flip gopt_unset Opt_ShowMatchesOfHoleFits -- nice but broken (forgets module qualifiers)
505471
$ flip gopt_unset Opt_ShowProvOfHoleFits -- not used
506472
$ flip gopt_unset Opt_ShowTypeAppOfHoleFits -- not used
@@ -533,12 +499,6 @@ disableWarningsAsErrors :: DynFlags -> DynFlags
533499
disableWarningsAsErrors df =
534500
flip gopt_unset Opt_WarnIsError $ foldl' wopt_unset_fatal df [toEnum 0 ..]
535501

536-
#if !MIN_VERSION_ghc(8,8,0)
537-
wopt_unset_fatal :: DynFlags -> WarningFlag -> DynFlags
538-
wopt_unset_fatal dfs f
539-
= dfs { fatalWarningFlags = EnumSet.delete f (fatalWarningFlags dfs) }
540-
#endif
541-
542502
isQualifiedImport :: ImportDecl a -> Bool
543503
#if MIN_VERSION_ghc(8,10,0)
544504
isQualifiedImport ImportDecl{ideclQualified = NotQualified} = False
@@ -606,8 +566,7 @@ generatedNodeInfo = sourceNodeInfo -- before ghc 9.0, we don't distinguish the s
606566
#endif
607567

608568
data GhcVersion
609-
= GHC86
610-
| GHC88
569+
= GHC88
611570
| GHC810
612571
| GHC90
613572
| GHC92
@@ -628,8 +587,6 @@ ghcVersion = GHC90
628587
ghcVersion = GHC810
629588
#elif MIN_VERSION_GLASGOW_HASKELL(8,8,0,0)
630589
ghcVersion = GHC88
631-
#elif MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)
632-
ghcVersion = GHC86
633590
#endif
634591

635592
runUnlit :: Logger -> DynFlags -> [Option] -> IO ()

ghcide/src/Development/IDE/GHC/Compat/CPP.hs

+5-16
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@ module Development.IDE.GHC.Compat.CPP (
1616
doCpp
1717
) where
1818

19-
import FileCleanup
20-
import Packages
21-
import Panic
22-
import SysTools
23-
#if MIN_VERSION_ghc(8,8,2)
24-
import LlvmCodeGen (llvmVersionList)
25-
#elif MIN_VERSION_ghc(8,8,0)
26-
import LlvmCodeGen (LlvmVersion (..))
27-
#endif
2819
import Control.Monad
2920
import Data.List (intercalate)
3021
import Data.Maybe
3122
import Data.Version
3223
import DynFlags
24+
import FileCleanup
25+
import LlvmCodeGen (llvmVersionList)
3326
import Module (rtsUnitId, toInstalledUnitId)
27+
import Packages
28+
import Panic
3429
import System.Directory
3530
import System.FilePath
3631
import System.Info
32+
import SysTools
3733

3834
import Development.IDE.GHC.Compat as Compat
3935

@@ -136,16 +132,9 @@ getBackendDefs :: DynFlags -> IO [String]
136132
getBackendDefs dflags | hscTarget dflags == HscLlvm = do
137133
llvmVer <- figureLlvmVersion dflags
138134
return $ case llvmVer of
139-
#if MIN_VERSION_ghc(8,8,2)
140135
Just v
141136
| [m] <- llvmVersionList v -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m, 0) ]
142137
| m:n:_ <- llvmVersionList v -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m, n) ]
143-
#elif MIN_VERSION_ghc(8,8,0)
144-
Just (LlvmVersion n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (n,0) ]
145-
Just (LlvmVersionOld m n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m,n) ]
146-
#else
147-
Just n -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format n ]
148-
#endif
149138
_ -> []
150139
where
151140
format (major, minor)

0 commit comments

Comments
 (0)