Skip to content

Commit 410d0d0

Browse files
committed
9.4 support for gadt and retrie plugins
1 parent 7dc9666 commit 410d0d0

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

haskell-language-server.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ common rename
262262
cpp-options: -Dhls_rename
263263

264264
common retrie
265-
if flag(retrie) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds))
265+
if flag(retrie)
266266
build-depends: hls-retrie-plugin ^>= 1.0
267267
cpp-options: -Dhls_retrie
268268

@@ -317,7 +317,7 @@ common changeTypeSignature
317317
cpp-options: -Dhls_changeTypeSignature
318318

319319
common gadt
320-
if flag(gadt) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds))
320+
if flag(gadt)
321321
build-depends: hls-gadt-plugin ^>= 1.0
322322
cpp-options: -Dhls_gadt
323323

plugins/hls-gadt-plugin/hls-gadt-plugin.cabal

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ source-repository head
2020
location: https://github.com/haskell/haskell-language-server.git
2121

2222
library
23-
if impl(ghc >= 9.3)
24-
buildable: False
25-
else
26-
buildable: True
2723
exposed-modules: Ide.Plugin.GADT
2824
other-modules: Ide.Plugin.GHC
2925

@@ -54,10 +50,6 @@ library
5450
default-extensions: DataKinds
5551

5652
test-suite tests
57-
if impl(ghc >= 9.3)
58-
buildable: False
59-
else
60-
buildable: True
6153
type: exitcode-stdio-1.0
6254
default-language: Haskell2010
6355
hs-source-dirs: test

plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ h98ToGADTConDecl dataName tyVars ctxt = \case
111111
renderDetails :: HsConDeclH98Details GP -> HsConDeclGADTDetails GP
112112
renderDetails (PrefixCon _ args) = PrefixConGADT args
113113
renderDetails (InfixCon arg1 arg2) = PrefixConGADT [arg1, arg2]
114+
#if MIN_VERSION_ghc(9,3,0)
115+
renderDetails (RecCon recs) = RecConGADT recs noHsUniTok
116+
#else
114117
renderDetails (RecCon recs) = RecConGADT recs
118+
#endif
119+
115120
#else
116121
renderDetails (PrefixCon args) = PrefixCon args
117122
renderDetails (InfixCon arg1 arg2) = PrefixCon [arg1, arg2]
@@ -185,7 +190,11 @@ prettyGADTDecl df decl =
185190
adjustTyClD = \case
186191
Right (L _ (TyClD _ tycld)) -> Right $ adjustDataDecl tycld
187192
Right x -> Left $ "Expect TyClD but got " <> showAst x
193+
#if MIN_VERSION_ghc(9,3,0)
194+
Left err -> Left $ printWithoutUniques err
195+
#else
188196
Left err -> Left $ show err
197+
#endif
189198

190199
adjustDataDecl DataDecl{..} = DataDecl
191200
{ tcdDExt = adjustWhere tcdDExt

plugins/hls-gadt-plugin/test/Main.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ tests = testGroup "GADT"
3535
, runTest "ConstructorContext" "ConstructorContext" 2 0 2 38
3636
, runTest "Context" "Context" 2 0 4 41
3737
, runTest "Pragma" "Pragma" 2 0 3 29
38-
, onlyWorkForGhcVersions (==GHC92) "Single deriving has different output on ghc9.2" $
38+
, onlyWorkForGhcVersions (`elem`[GHC92, GHC94]) "Single deriving has different output on ghc9.2+" $
3939
runTest "SingleDerivingGHC92" "SingleDerivingGHC92" 2 0 3 14
40-
, knownBrokenForGhcVersions [GHC92] "Single deriving has different output on ghc9.2" $
40+
, knownBrokenForGhcVersions [GHC92,GHC94] "Single deriving has different output on ghc9.2+" $
4141
runTest "SingleDeriving" "SingleDeriving" 2 0 3 14
42-
, onlyWorkForGhcVersions (==GHC92) "only ghc-9.2 enabled GADTs pragma implicitly" $
42+
, onlyWorkForGhcVersions (`elem`[GHC92, GHC94]) "only ghc-9.2+ enabled GADTs pragma implicitly" $
4343
gadtPragmaTest "ghc-9.2 don't need to insert GADTs pragma" False
44-
, knownBrokenForGhcVersions [GHC92] "ghc-9.2 has enabled GADTs pragma implicitly" $
44+
, knownBrokenForGhcVersions [GHC92,GHC94] "ghc-9.2 has enabled GADTs pragma implicitly" $
4545
gadtPragmaTest "insert pragma" True
4646
]
4747

plugins/hls-retrie-plugin/hls-retrie-plugin.cabal

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ source-repository head
1717
location: https://github.com/haskell/haskell-language-server.git
1818

1919
library
20-
if impl(ghc >= 9.3)
21-
buildable: False
22-
else
23-
buildable: True
2420
exposed-modules: Ide.Plugin.Retrie
2521
hs-source-dirs: src
2622
build-depends:

plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ import Language.LSP.Types as J hiding
9696
import Retrie.CPP (CPP (NoCPP), parseCPP)
9797
import Retrie.ExactPrint (Annotated, fix,
9898
transformA, unsafeMkA)
99+
100+
#if MIN_VERSION_ghc(9,3,0)
101+
import GHC.Types.PkgQual
102+
#endif
103+
99104
#if MIN_VERSION_ghc(9,2,0)
100105
import Retrie.ExactPrint (makeDeltaAst)
101106
#else
@@ -548,7 +553,11 @@ toImportDecl AddImport {..} = GHC.ImportDecl {ideclSource = ideclSource', ..}
548553
ideclSource' = if ideclSource then IsBoot else NotBoot
549554
toMod = noLocA . GHC.mkModuleName
550555
ideclName = toMod ideclNameString
556+
#if MIN_VERSION_ghc(9,3,0)
557+
ideclPkgQual = NoRawPkgQual
558+
#else
551559
ideclPkgQual = Nothing
560+
#endif
552561
ideclSafe = False
553562
ideclImplicit = False
554563
ideclHiding = Nothing

0 commit comments

Comments
 (0)