From 3773e14ef34b6f1e78acfb28876ad11b16e34347 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 5 Sep 2023 14:09:58 +0200 Subject: [PATCH 01/11] Bump ghc version bounds for GHC 9.6 --- ghc-source-gen.cabal | 8 ++++---- package.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ghc-source-gen.cabal b/ghc-source-gen.cabal index e5c7799..19bf18e 100644 --- a/ghc-source-gen.cabal +++ b/ghc-source-gen.cabal @@ -61,7 +61,7 @@ library TypeSynonymInstances build-depends: base >=4.7 && <5 - , ghc >=8.4 && <9.5 + , ghc >=8.4 && <9.7 if impl(ghc<8.10) other-modules: GHC.Hs @@ -104,7 +104,7 @@ test-suite name_test build-depends: QuickCheck >=2.10 && <2.15 , base >=4.7 && <5 - , ghc >=8.4 && <9.5 + , ghc >=8.4 && <9.7 , ghc-source-gen , tasty >=1.0 && <1.5 , tasty-hunit ==0.10.* @@ -125,7 +125,7 @@ test-suite pprint_examples TypeSynonymInstances build-depends: base >=4.7 && <5 - , ghc >=8.4 && <9.5 + , ghc >=8.4 && <9.7 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.5 @@ -151,7 +151,7 @@ test-suite pprint_test TypeSynonymInstances build-depends: base >=4.7 && <5 - , ghc >=8.4 && <9.5 + , ghc >=8.4 && <9.7 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.5 diff --git a/package.yaml b/package.yaml index eb733ab..f601753 100644 --- a/package.yaml +++ b/package.yaml @@ -30,7 +30,7 @@ description: | dependencies: - base >= 4.7 && < 5 -- ghc >= 8.4 && < 9.5 +- ghc >= 8.4 && < 9.7 default-extensions: - DataKinds From 1e5244e4025302e8b028d02714682185f1f4b626 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Wed, 13 Sep 2023 12:17:53 +0200 Subject: [PATCH 02/11] Support GHC 9.6 --- src/GHC/SourceGen/Binds.hs | 4 ++ src/GHC/SourceGen/Binds/Internal.hs | 12 +++++- src/GHC/SourceGen/Decl.hs | 31 ++++++++++++-- src/GHC/SourceGen/Expr.hs | 15 +++++-- src/GHC/SourceGen/Module.hs | 61 ++++++++++++++++++++++++---- src/GHC/SourceGen/Overloaded.hs | 11 ++++- src/GHC/SourceGen/Pat.hs | 10 ++++- src/GHC/SourceGen/Syntax/Internal.hs | 2 +- 8 files changed, 127 insertions(+), 19 deletions(-) diff --git a/src/GHC/SourceGen/Binds.hs b/src/GHC/SourceGen/Binds.hs index 4137c46..b4e7e9e 100644 --- a/src/GHC/SourceGen/Binds.hs +++ b/src/GHC/SourceGen/Binds.hs @@ -106,7 +106,9 @@ funBindsWithFixity fixity name matches = bindB $ withPlaceHolder WpHole #endif ) +#if !MIN_VERSION_ghc(9,6,0) [] +#endif where name' = valueRdrName $ unqual name occ = valueOccName name @@ -189,7 +191,9 @@ patBindGRHSs p g = $ withPlaceHolder (withPlaceHolder (withEpAnnNotUsed PatBind (builtPat p) (mkGRHSs g))) +#if !MIN_VERSION_ghc(9,6,0) $ ([],[]) +#endif -- | Defines a pattern binding without any guards. -- diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index 99605cf..079dc5c 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -24,6 +24,7 @@ import PlaceHolder (PlaceHolder(..)) import GHC.SourceGen.Pat.Internal (parenthesize) import GHC.SourceGen.Syntax.Internal +import GHC (noExtField, NoExtField (NoExtField)) -- | A binding definition inside of a @let@ or @where@ clause. -- @@ -83,12 +84,19 @@ data RawGRHSs = RawGRHSs matchGroup :: HsMatchContext' -> [RawMatch] -> MatchGroup' LHsExpr' matchGroup context matches = - noExt MG (mkLocated $ map (mkLocated . mkMatch) matches) +#if MIN_VERSION_ghc(9,6,0) + MG Generated +#else + noExt MG +#endif + matches' #if !MIN_VERSION_ghc(8,6,0) [] PlaceHolder -#endif +#elif !MIN_VERSION_ghc(9,6,0) Generated +#endif where + matches' = mkLocated $ map (mkLocated . mkMatch) matches mkMatch :: RawMatch -> Match' LHsExpr' mkMatch r = withEpAnnNotUsed Match context (map builtPat $ map parenthesize $ rawMatchPats r) diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 35acdc0..1c76a4c 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -51,10 +51,20 @@ module GHC.SourceGen.Decl , patSynBind ) where +#if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) +import GHC.Types.SrcLoc (LayoutInfo(..)) +#endif #if MIN_VERSION_ghc(9,0,0) import GHC (LexicalFixity(Prefix)) import GHC.Data.Bag (listToBag) + +#if MIN_VERSION_ghc(9,6,0) +import GHC (GhcPs, LayoutInfo (NoLayoutInfo)) +#else +import GHC (GhcPs) import GHC.Types.SrcLoc (LayoutInfo(..)) +#endif + #else import BasicTypes (LexicalFixity(Prefix)) import Bag (listToBag) @@ -62,7 +72,6 @@ import Bag (listToBag) #if !MIN_VERSION_ghc(8,6,0) import BasicTypes (DerivStrategy(..)) #endif -import GHC (GhcPs) import GHC.Hs.Binds import GHC.Hs.Decls @@ -108,6 +117,7 @@ import GHC.SourceGen.Name import GHC.SourceGen.Name.Internal import GHC.SourceGen.Syntax.Internal import GHC.SourceGen.Type.Internal +import GHC.Hs -- | A definition that can appear in the body of a @class@ declaration. -- @@ -174,7 +184,10 @@ class' class' context name vars decls = noExt TyClD $ ClassDecl { tcdCtxt = toHsContext $ mkLocated $ map mkLocated context -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,6,0) + , tcdLayout = NoLayoutInfo + , tcdCExt = (EpAnnNotUsed, NoAnnSortKey) +#elif MIN_VERSION_ghc(9,2,0) , tcdCExt = (EpAnnNotUsed, NoAnnSortKey, NoLayoutInfo) #elif MIN_VERSION_ghc(9,0,0) , tcdCExt = NoLayoutInfo @@ -323,11 +336,23 @@ newOrDataType newOrData name vars conDecls derivs withEpAnnNotUsed DataDecl (typeRdrName $ unqual name) (mkQTyVars vars) Prefix - $ noExt HsDataDefn newOrData + $ noExt HsDataDefn +#if !MIN_VERSION_ghc(9,6,0) + newOrData +#endif cxt Nothing Nothing +#if MIN_VERSION_ghc(9,6,0) + (case newOrData of + NewType -> case conDecls of + [decl] -> NewTypeCon $ mkLocated decl + _ -> error "NewTypeCon with more than one decl" + DataType -> DataTypeCons False (map mkLocated conDecls) + ) +#else (map mkLocated conDecls) +#endif #if MIN_VERSION_ghc(9,4,0) (toHsDeriving $ map mkLocated derivs) #else diff --git a/src/GHC/SourceGen/Expr.hs b/src/GHC/SourceGen/Expr.hs index 6cded38..e506bcf 100644 --- a/src/GHC/SourceGen/Expr.hs +++ b/src/GHC/SourceGen/Expr.hs @@ -29,7 +29,11 @@ module GHC.SourceGen.Expr ) where import GHC.Hs.Expr -import GHC.Hs.Extension (GhcPs) +import GHC.Hs.Extension (GhcPs +#if MIN_VERSION_ghc(9,6,0) + , noHsTok +#endif + ) #if MIN_VERSION_ghc(9,4,0) import GHC.Hs.Pat (HsFieldBind(..), HsRecFields(..)) #else @@ -58,6 +62,7 @@ import GHC.SourceGen.Type.Internal , sigWcType , wcType ) +import GHC.Types.SourceText (SourceText(NoSourceText)) -- | An overloaded label, as used with the @OverloadedLabels@ extension. -- @@ -67,7 +72,9 @@ import GHC.SourceGen.Type.Internal overLabel :: String -> HsExpr' overLabel = hsOverLabel . fromString where -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,6,0) + hsOverLabel = withEpAnnNotUsed HsOverLabel NoSourceText +#elif MIN_VERSION_ghc(9,2,0) hsOverLabel = withEpAnnNotUsed HsOverLabel #else hsOverLabel = noExt HsOverLabel Nothing @@ -198,7 +205,9 @@ e @::@ t = ExprWithTySig (builtLoc e) (sigWcType t) -- > ===== -- > var "f" @@ var "Int" tyApp :: HsExpr' -> HsType' -> HsExpr' -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,6,0) +tyApp e t = noExt HsAppType e' noHsTok t' +#elif MIN_VERSION_ghc(9,2,0) tyApp e t = HsAppType builtSpan e' t' #elif MIN_VERSION_ghc(8,8,0) tyApp e t = noExt HsAppType e' t' diff --git a/src/GHC/SourceGen/Module.hs b/src/GHC/SourceGen/Module.hs index 7745b6b..a2e09d3 100644 --- a/src/GHC/SourceGen/Module.hs +++ b/src/GHC/SourceGen/Module.hs @@ -26,7 +26,12 @@ module GHC.SourceGen.Module , moduleContents ) where -import GHC.Hs.ImpExp (LIEWrappedName, IEWildcard(..), IEWrappedName(..), IE(..)) +import GHC.Hs.ImpExp + ( LIEWrappedName, IEWildcard(..), IEWrappedName(..), IE(..) +#if MIN_VERSION_ghc(9,6,0) + , ImportListInterpretation (EverythingBut, Exactly), XImportDeclPass (ideclSourceText, ideclImplicit) +#endif + ) import GHC.Hs ( HsModule(..) , ImportDecl(..) @@ -35,10 +40,15 @@ import GHC.Hs #endif #if MIN_VERSION_ghc(9,2,0) , EpAnn(..) +#endif +#if MIN_VERSION_ghc(9,6,0) + , hsmodDeprecMessage, hsmodHaddockModHeader, hsmodAnn, AnnKeywordId, XModulePs (XModulePs, hsmodLayout), noAnn, LayoutInfo (NoLayoutInfo), GhcPs, XImportDeclPass (XImportDeclPass, ideclAnn), SrcSpanAnnA, noExtField #endif ) -#if MIN_VERSION_ghc(9,0,0) +#if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) import GHC.Types.SrcLoc (LayoutInfo(..)) +#endif +#if MIN_VERSION_ghc(9,0,0) import GHC.Unit.Module (IsBootInterface(..)) import GHC.Types.Name.Reader (RdrName) #else @@ -50,8 +60,11 @@ import GHC.Types.PkgQual (RawPkgQual(..)) import GHC.SourceGen.Syntax.Internal import GHC.SourceGen.Name + ( RdrNameStr, ModuleNameStr(unModuleNameStr), OccNameStr, unqual ) import GHC.SourceGen.Name.Internal import GHC.SourceGen.Lit.Internal (noSourceText) +import GHC.Types.SourceText (SourceText(NoSourceText)) +import GHC.Types.SrcLoc (GenLocated) module' :: Maybe ModuleNameStr @@ -64,13 +77,21 @@ module' name exports imports decls = HsModule , hsmodExports = fmap (mkLocated . map mkLocated) exports , hsmodImports = map mkLocated imports , hsmodDecls = fmap mkLocated decls +#if MIN_VERSION_ghc(9,6,0) + , hsmodExt = XModulePs + { hsmodAnn = noAnn + , hsmodLayout = NoLayoutInfo + , hsmodDeprecMessage = Nothing + , hsmodHaddockModHeader = Nothing } +#else , hsmodDeprecMessage = Nothing , hsmodHaddockModHeader = Nothing -#if MIN_VERSION_ghc(9,0,0) +# if MIN_VERSION_ghc(9,0,0) , hsmodLayout = NoLayoutInfo -#endif -#if MIN_VERSION_ghc(9,2,0) +# endif +# if MIN_VERSION_ghc(9,2,0) , hsmodAnn = EpAnnNotUsed +# endif #endif } @@ -87,7 +108,7 @@ as' :: ImportDecl' -> ModuleNameStr -> ImportDecl' as' d m = d { ideclAs = Just (mkLocated $ unModuleNameStr m) } import' :: ModuleNameStr -> ImportDecl' -import' m = noSourceText (withEpAnnNotUsed ImportDecl) +import' m = importDecl (mkLocated $ unModuleNameStr m) #if MIN_VERSION_ghc(9,4,0) NoRawPkgQual @@ -105,15 +126,36 @@ import' m = noSourceText (withEpAnnNotUsed ImportDecl) #else False #endif - False Nothing Nothing +#if !MIN_VERSION_ghc(9,6,0) + False +#endif + Nothing Nothing + where +#if MIN_VERSION_ghc(9,6,0) + importDecl = ImportDecl + (XImportDeclPass{ ideclAnn = EpAnnNotUsed + , ideclSourceText = NoSourceText + , ideclImplicit = False + }) +#else + importDecl = noSourceText (withEpAnnNotUsed ImportDecl) +#endif exposing :: ImportDecl' -> [IE'] -> ImportDecl' exposing d ies = d +#if MIN_VERSION_ghc(9,6,0) + { ideclImportList = Just (Exactly, mkLocated $ map mkLocated ies) } +#else { ideclHiding = Just (False, mkLocated $ map mkLocated ies) } +#endif hiding :: ImportDecl' -> [IE'] -> ImportDecl' hiding d ies = d +#if MIN_VERSION_ghc(9,6,0) + { ideclImportList = Just (EverythingBut, mkLocated $ map mkLocated ies) } +#else { ideclHiding = Just (True, mkLocated $ map mkLocated ies) } +#endif -- | Adds the @{-# SOURCE #-}@ pragma to an import. source :: ImportDecl' -> ImportDecl' @@ -150,8 +192,13 @@ thingWith n cs = withEpAnnNotUsed IEThingWith (wrappedName n) NoIEWildcard -- TODO: support "mixed" syntax with both ".." and explicit names. +#if MIN_VERSION_ghc(9,6,0) +wrappedName :: RdrNameStr -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs) +wrappedName rNameStr = mkLocated (IEName noExtField $ exportRdrName rNameStr) +#else wrappedName :: RdrNameStr -> LIEWrappedName RdrName wrappedName = mkLocated . IEName . exportRdrName +#endif -- | Exports an entire module. -- diff --git a/src/GHC/SourceGen/Overloaded.hs b/src/GHC/SourceGen/Overloaded.hs index 7d3a1d5..ef486dd 100644 --- a/src/GHC/SourceGen/Overloaded.hs +++ b/src/GHC/SourceGen/Overloaded.hs @@ -22,7 +22,7 @@ import GHC.Hs.Type ( HsType(..) , HsTyVarBndr(..) ) -import GHC.Hs (IE(..), IEWrappedName(..)) +import GHC.Hs (IE(..), IEWrappedName(..), noExtField) #if !MIN_VERSION_ghc(8,6,0) import PlaceHolder(PlaceHolder(..)) #endif @@ -286,7 +286,14 @@ instance BVar HsTyVarBndr' where #endif instance Var IE' where - var n = noExt IEVar $ mkLocated $ IEName $ exportRdrName n + var n = + noExt IEVar $ mkLocated $ +#if MIN_VERSION_ghc(9,6,0) + (IEName noExtField) +#else + IEName +#endif + $ exportRdrName n instance BVar IE' where bvar = var . UnqualStr diff --git a/src/GHC/SourceGen/Pat.hs b/src/GHC/SourceGen/Pat.hs index 5f74595..9f82370 100644 --- a/src/GHC/SourceGen/Pat.hs +++ b/src/GHC/SourceGen/Pat.hs @@ -29,6 +29,9 @@ import GHC.SourceGen.Type.Internal (patSigType) #if MIN_VERSION_ghc(9,2,0) import GHC.Parser.Annotation (EpAnn(..)) #endif +#if MIN_VERSION_ghc(9,6,0) +import GHC (noHsTok) +#endif -- | A wild pattern (@_@). wildP :: Pat' @@ -40,7 +43,12 @@ wildP = noExtOrPlaceHolder WildPat -- > ===== -- > asP "a" (var "B") asP :: RdrNameStr -> Pat' -> Pat' -v `asP` p = withEpAnnNotUsed AsPat (valueRdrName v) $ builtPat $ parenthesize p +v `asP` p = + withEpAnnNotUsed AsPat (valueRdrName v) +#if MIN_VERSION_ghc(9,6,0) + noHsTok +#endif + (builtPat $ parenthesize p) -- | A pattern constructor. -- diff --git a/src/GHC/SourceGen/Syntax/Internal.hs b/src/GHC/SourceGen/Syntax/Internal.hs index a5bc7f5..e5cc569 100644 --- a/src/GHC/SourceGen/Syntax/Internal.hs +++ b/src/GHC/SourceGen/Syntax/Internal.hs @@ -290,7 +290,7 @@ type HsTyVarBndrS' = HsTyVarBndr GhcPs #endif type HsLit' = HsLit GhcPs -#if MIN_VERSION_ghc(9,0,0) +#if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) type HsModule' = HsModule #else type HsModule' = HsModule GhcPs From bb79a74358a09af40cbbfdc4d4dd2d0a22b3a923 Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Tue, 21 Nov 2023 09:57:28 -0800 Subject: [PATCH 03/11] Remove some trailing whitespace --- src/GHC/SourceGen/Binds.hs | 4 ++-- src/GHC/SourceGen/Module.hs | 6 +++--- src/GHC/SourceGen/Overloaded.hs | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/GHC/SourceGen/Binds.hs b/src/GHC/SourceGen/Binds.hs index b4e7e9e..98e1b08 100644 --- a/src/GHC/SourceGen/Binds.hs +++ b/src/GHC/SourceGen/Binds.hs @@ -101,7 +101,7 @@ typeSig n = typeSigs [n] funBindsWithFixity :: HasValBind t => Maybe LexicalFixity -> OccNameStr -> [RawMatch] -> t funBindsWithFixity fixity name matches = bindB $ withPlaceHolder (noExt FunBind name' - (matchGroup context matches) + (matchGroup context matches) #if !MIN_VERSION_ghc(9,0,1) WpHole #endif @@ -191,7 +191,7 @@ patBindGRHSs p g = $ withPlaceHolder (withPlaceHolder (withEpAnnNotUsed PatBind (builtPat p) (mkGRHSs g))) -#if !MIN_VERSION_ghc(9,6,0) +#if !MIN_VERSION_ghc(9,6,0) $ ([],[]) #endif diff --git a/src/GHC/SourceGen/Module.hs b/src/GHC/SourceGen/Module.hs index a2e09d3..ede89e7 100644 --- a/src/GHC/SourceGen/Module.hs +++ b/src/GHC/SourceGen/Module.hs @@ -113,7 +113,7 @@ import' m = importDecl #if MIN_VERSION_ghc(9,4,0) NoRawPkgQual #else - Nothing + Nothing #endif #if MIN_VERSION_ghc(9,0,0) NotBoot @@ -132,14 +132,14 @@ import' m = importDecl Nothing Nothing where #if MIN_VERSION_ghc(9,6,0) - importDecl = ImportDecl + importDecl = ImportDecl (XImportDeclPass{ ideclAnn = EpAnnNotUsed , ideclSourceText = NoSourceText , ideclImplicit = False }) #else importDecl = noSourceText (withEpAnnNotUsed ImportDecl) -#endif +#endif exposing :: ImportDecl' -> [IE'] -> ImportDecl' exposing d ies = d diff --git a/src/GHC/SourceGen/Overloaded.hs b/src/GHC/SourceGen/Overloaded.hs index ef486dd..fa636c4 100644 --- a/src/GHC/SourceGen/Overloaded.hs +++ b/src/GHC/SourceGen/Overloaded.hs @@ -288,7 +288,7 @@ instance BVar HsTyVarBndr' where instance Var IE' where var n = noExt IEVar $ mkLocated $ -#if MIN_VERSION_ghc(9,6,0) +#if MIN_VERSION_ghc(9,6,0) (IEName noExtField) #else IEName @@ -297,4 +297,3 @@ instance Var IE' where instance BVar IE' where bvar = var . UnqualStr - From c4aa34ec327c2ee23233aa55cebd65e83c9360c2 Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Tue, 21 Nov 2023 10:02:05 -0800 Subject: [PATCH 04/11] Start fixing hiding unused imports, more to come --- src/GHC/SourceGen/Syntax/Internal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GHC/SourceGen/Syntax/Internal.hs b/src/GHC/SourceGen/Syntax/Internal.hs index e5cc569..c1a2c2c 100644 --- a/src/GHC/SourceGen/Syntax/Internal.hs +++ b/src/GHC/SourceGen/Syntax/Internal.hs @@ -62,7 +62,7 @@ import RdrName (RdrName) import SrcLoc (SrcSpan, Located, GenLocated(..), mkGeneralSrcSpan) #endif -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,2,0) && !MIN_VERSION_ghc(9,6,0) import GHC.Parser.Annotation ( SrcSpanAnn'(..) , AnnSortKey(..) From 671bd5471077b34057f86fef76852d347dcf0acf Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 14:48:33 +0100 Subject: [PATCH 05/11] Add stack config for GHC 9.6 --- stack-9.6.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 stack-9.6.yaml diff --git a/stack-9.6.yaml b/stack-9.6.yaml new file mode 100644 index 0000000..e512d69 --- /dev/null +++ b/stack-9.6.yaml @@ -0,0 +1,15 @@ +# Copyright 2019 Google LLC +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +resolver: nightly-2023-11-21 +compiler: ghc-9.6.3 + +packages: +- . +- ghc-show-ast + +ghc-options: + "$locals": -Wall -Werror From d8b3008d280374a6b1c5494cc345a803f3a4a292 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 14:49:41 +0100 Subject: [PATCH 06/11] Add stack config for GHC 9.4 --- stack-9.4.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 stack-9.4.yaml diff --git a/stack-9.4.yaml b/stack-9.4.yaml new file mode 100644 index 0000000..6a31484 --- /dev/null +++ b/stack-9.4.yaml @@ -0,0 +1,15 @@ +# Copyright 2019 Google LLC +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +resolver: lts-21.25 +compiler: ghc-9.4.8 + +packages: +- . +- ghc-show-ast + +ghc-options: + "$locals": -Wall -Werror From 29b8042b9dca5107b0fd677f3e4b05f5c74a26ba Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 15:13:45 +0100 Subject: [PATCH 07/11] Use GHC 9.2.8 with lts-20.26 --- stack-9.2.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack-9.2.yaml b/stack-9.2.yaml index 1b38645..0bcc3e3 100644 --- a/stack-9.2.yaml +++ b/stack-9.2.yaml @@ -4,8 +4,8 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd -resolver: nightly-2022-08-19 -compiler: ghc-9.2.4 +resolver: lts-20.26 +compiler: ghc-9.2.8 packages: - . From 859f4695372a18271e2f63aae564316ecf3ca0f0 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 14:52:32 +0100 Subject: [PATCH 08/11] Adapt ghc-show-ast for GHC 9.6 --- ghc-show-ast/Main.hs | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/ghc-show-ast/Main.hs b/ghc-show-ast/Main.hs index 2b93aac..49f25a4 100644 --- a/ghc-show-ast/Main.hs +++ b/ghc-show-ast/Main.hs @@ -13,7 +13,14 @@ import Data.Typeable (cast) import System.Environment (getArgs) import Text.PrettyPrint -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) +import GHC.Driver.Config.Diagnostic (initDiagOpts) +import GHC.Driver.Config.Parser (initParserOpts) +import qualified GHC.Driver.Errors as Error (printMessages) +#if MIN_VERSION_ghc(9,6,0) +import qualified GHC.Types.Error as GHC (NoDiagnosticOpts(..)) +#endif +#elif MIN_VERSION_ghc(9,2,0) import qualified GHC.Driver.Errors as Error import qualified GHC.Parser.Errors.Ppr as Error #elif MIN_VERSION_ghc(9,0,0) @@ -103,7 +110,7 @@ main = do result <- parseModule f print $ gPrint result -#if MIN_VERSION_ghc(9,0,1) +#if MIN_VERSION_ghc(9,0,1) && !MIN_VERSION_ghc(9,6,0) parseModule :: FilePath -> IO GHC.HsModule #else parseModule :: FilePath -> IO (GHC.HsModule GHC.GhcPs) @@ -111,10 +118,27 @@ parseModule :: FilePath -> IO (GHC.HsModule GHC.GhcPs) parseModule f = GHC.runGhc (Just libdir) $ do dflags <- GHC.getDynFlags contents <- GHC.liftIO $ GHC.stringToStringBuffer <$> readFile f +#if MIN_VERSION_ghc(9,4,0) + let (_, options) = GHC.getOptions (initParserOpts dflags) contents f +#else let options = GHC.getOptions dflags contents f +#endif (dflags', _, _) <- GHC.parseDynamicFilePragma dflags options -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) + let diagOpts = initDiagOpts dflags' + state = + GHC.initParserState + ( GHC.mkParserOpts + (GHC.extensionFlags dflags') + diagOpts + [] + (GHC.safeImportsOn dflags') + (GHC.gopt GHC.Opt_Haddock dflags') + (GHC.gopt GHC.Opt_KeepRawTokenStream dflags') + True + ) +#elif MIN_VERSION_ghc(9,2,0) let state = GHC.initParserState ( GHC.mkParserOpts @@ -135,7 +159,18 @@ parseModule f = GHC.runGhc (Just libdir) $ do case GHC.unP Parser.parseModule state of GHC.POk _state m -> return $ GHC.unLoc m -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,4,0) + GHC.PFailed s -> do + logger <- GHC.getLogger + liftIO $ do + let errors = GHC.getPsErrorMessages s +# if MIN_VERSION_ghc(9,6,0) + Error.printMessages logger GHC.NoDiagnosticOpts diagOpts errors +# else + Error.printMessages logger diagOpts errors +# endif + exitFailure +#elif MIN_VERSION_ghc(9,2,0) GHC.PFailed s -> do logger <- GHC.getLogger liftIO $ do From 3b3dabc962acaff52542e30183987b606825442a Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 14:53:15 +0100 Subject: [PATCH 09/11] Remove unused imports --- src/GHC/SourceGen/Binds/Internal.hs | 1 - src/GHC/SourceGen/Module.hs | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index 079dc5c..9a5124d 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -24,7 +24,6 @@ import PlaceHolder (PlaceHolder(..)) import GHC.SourceGen.Pat.Internal (parenthesize) import GHC.SourceGen.Syntax.Internal -import GHC (noExtField, NoExtField (NoExtField)) -- | A binding definition inside of a @let@ or @where@ clause. -- diff --git a/src/GHC/SourceGen/Module.hs b/src/GHC/SourceGen/Module.hs index ede89e7..1d9340a 100644 --- a/src/GHC/SourceGen/Module.hs +++ b/src/GHC/SourceGen/Module.hs @@ -27,9 +27,11 @@ module GHC.SourceGen.Module ) where import GHC.Hs.ImpExp - ( LIEWrappedName, IEWildcard(..), IEWrappedName(..), IE(..) + ( IEWildcard(..), IEWrappedName(..), IE(..) #if MIN_VERSION_ghc(9,6,0) , ImportListInterpretation (EverythingBut, Exactly), XImportDeclPass (ideclSourceText, ideclImplicit) +#else + , LIEWrappedName #endif ) import GHC.Hs @@ -59,12 +61,16 @@ import GHC.Types.PkgQual (RawPkgQual(..)) #endif import GHC.SourceGen.Syntax.Internal -import GHC.SourceGen.Name - ( RdrNameStr, ModuleNameStr(unModuleNameStr), OccNameStr, unqual ) import GHC.SourceGen.Name.Internal import GHC.SourceGen.Lit.Internal (noSourceText) +#if MIN_VERSION_ghc(9,0,0) +import GHC.SourceGen.Name (unqual) +#endif +#if MIN_VERSION_ghc(9,4,0) +import GHC.SourceGen.Name (RdrNameStr, ModuleNameStr(unModuleNameStr), OccNameStr) import GHC.Types.SourceText (SourceText(NoSourceText)) import GHC.Types.SrcLoc (GenLocated) +#endif module' :: Maybe ModuleNameStr From 7e05333cfe6e95a7802b489fa85ad62940b2ac9c Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 16:16:20 +0100 Subject: [PATCH 10/11] Guard imports for GHC versions --- src/GHC/SourceGen/Decl.hs | 6 +----- src/GHC/SourceGen/Expr.hs | 7 +++---- src/GHC/SourceGen/Overloaded.hs | 6 +++++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 1c76a4c..ee12956 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -51,9 +51,6 @@ module GHC.SourceGen.Decl , patSynBind ) where -#if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) -import GHC.Types.SrcLoc (LayoutInfo(..)) -#endif #if MIN_VERSION_ghc(9,0,0) import GHC (LexicalFixity(Prefix)) import GHC.Data.Bag (listToBag) @@ -61,8 +58,7 @@ import GHC.Data.Bag (listToBag) #if MIN_VERSION_ghc(9,6,0) import GHC (GhcPs, LayoutInfo (NoLayoutInfo)) #else -import GHC (GhcPs) -import GHC.Types.SrcLoc (LayoutInfo(..)) +import GHC.Types.SrcLoc (LayoutInfo(NoLayoutInfo)) #endif #else diff --git a/src/GHC/SourceGen/Expr.hs b/src/GHC/SourceGen/Expr.hs index e506bcf..49c5c55 100644 --- a/src/GHC/SourceGen/Expr.hs +++ b/src/GHC/SourceGen/Expr.hs @@ -29,11 +29,11 @@ module GHC.SourceGen.Expr ) where import GHC.Hs.Expr -import GHC.Hs.Extension (GhcPs +import GHC.Hs.Extension (GhcPs) #if MIN_VERSION_ghc(9,6,0) - , noHsTok +import GHC.Hs.Extension (noHsTok) +import GHC.Types.SourceText (SourceText(NoSourceText)) #endif - ) #if MIN_VERSION_ghc(9,4,0) import GHC.Hs.Pat (HsFieldBind(..), HsRecFields(..)) #else @@ -62,7 +62,6 @@ import GHC.SourceGen.Type.Internal , sigWcType , wcType ) -import GHC.Types.SourceText (SourceText(NoSourceText)) -- | An overloaded label, as used with the @OverloadedLabels@ extension. -- diff --git a/src/GHC/SourceGen/Overloaded.hs b/src/GHC/SourceGen/Overloaded.hs index fa636c4..762e81d 100644 --- a/src/GHC/SourceGen/Overloaded.hs +++ b/src/GHC/SourceGen/Overloaded.hs @@ -22,7 +22,11 @@ import GHC.Hs.Type ( HsType(..) , HsTyVarBndr(..) ) -import GHC.Hs (IE(..), IEWrappedName(..), noExtField) +import GHC.Hs (IE(..), IEWrappedName(..) +#if MIN_VERSION_ghc(9,6,0) + , noExtField +#endif + ) #if !MIN_VERSION_ghc(8,6,0) import PlaceHolder(PlaceHolder(..)) #endif From e6407fb8deccdee7b6d6bedb9b0287d0a90d63fa Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 19 Dec 2023 18:56:24 +0100 Subject: [PATCH 11/11] Only warn about dogdy and unused imports --- stack-9.0.yaml | 2 +- stack-9.2.yaml | 2 +- stack-9.4.yaml | 2 +- stack-9.6.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stack-9.0.yaml b/stack-9.0.yaml index 3d5b32d..b463ce3 100644 --- a/stack-9.0.yaml +++ b/stack-9.0.yaml @@ -11,4 +11,4 @@ packages: - ghc-show-ast ghc-options: - "$locals": -Wall -Werror + "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports diff --git a/stack-9.2.yaml b/stack-9.2.yaml index 0bcc3e3..da6d321 100644 --- a/stack-9.2.yaml +++ b/stack-9.2.yaml @@ -12,4 +12,4 @@ packages: - ghc-show-ast ghc-options: - "$locals": -Wall -Werror + "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports diff --git a/stack-9.4.yaml b/stack-9.4.yaml index 6a31484..cb92c0e 100644 --- a/stack-9.4.yaml +++ b/stack-9.4.yaml @@ -12,4 +12,4 @@ packages: - ghc-show-ast ghc-options: - "$locals": -Wall -Werror + "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports diff --git a/stack-9.6.yaml b/stack-9.6.yaml index e512d69..440029e 100644 --- a/stack-9.6.yaml +++ b/stack-9.6.yaml @@ -12,4 +12,4 @@ packages: - ghc-show-ast ghc-options: - "$locals": -Wall -Werror + "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports