From a06e9b511ab5539d69e78e1d27e86df347177246 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 09:13:57 +0200 Subject: [PATCH 01/12] Add stack config for GHC 9.12 --- stack-9.12.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 stack-9.12.yaml diff --git a/stack-9.12.yaml b/stack-9.12.yaml new file mode 100644 index 0000000..0ec7802 --- /dev/null +++ b/stack-9.12.yaml @@ -0,0 +1,17 @@ +# 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-2025-08-23 +compiler: ghc-9.12.2 + +packages: +- . +- ghc-show-ast + +ghc-options: + "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports + +allow-newer: true From b907662736e06d5e817c57fd28b14a2959037cd2 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 13:57:45 +0200 Subject: [PATCH 02/12] working for GHC 9.12 --- src/GHC/SourceGen/Binds.hs | 11 +++++- src/GHC/SourceGen/Binds/Internal.hs | 23 ++++++++--- src/GHC/SourceGen/Decl.hs | 61 +++++++++++++++++------------ src/GHC/SourceGen/Expr.hs | 36 ++++++++++------- src/GHC/SourceGen/Lit.hs | 3 +- src/GHC/SourceGen/Module.hs | 8 ++-- src/GHC/SourceGen/Overloaded.hs | 24 +++++++----- src/GHC/SourceGen/Pat.hs | 16 ++++---- src/GHC/SourceGen/Pat/Internal.hs | 4 +- src/GHC/SourceGen/Type.hs | 19 +++++---- src/GHC/SourceGen/Type/Internal.hs | 4 +- 11 files changed, 128 insertions(+), 81 deletions(-) diff --git a/src/GHC/SourceGen/Binds.hs b/src/GHC/SourceGen/Binds.hs index 97e93c8..729cea3 100644 --- a/src/GHC/SourceGen/Binds.hs +++ b/src/GHC/SourceGen/Binds.hs @@ -81,7 +81,11 @@ typeSigs names t = sigB $ TypeSig ann (map (typeRdrName . unqual) names) $ sigWcType t where +# if MIN_VERSION_ghc(9,12,0) + ann = AnnSig noAnn Nothing Nothing +# else ann = AnnSig noAnn [] +# endif #else sigB $ withEpAnnNotUsed TypeSig (map (typeRdrName . unqual) names) $ sigWcType t @@ -124,7 +128,11 @@ funBindsWithFixity fixity name matches = bindB $ withPlaceHolder name' = valueRdrName $ unqual name occ = valueOccName name fixity' = fromMaybe (bool Prefix Infix $ isSymOcc occ) fixity +#if MIN_VERSION_ghc(9,12,0) + context = FunRhs name' fixity' NoSrcStrict noAnn +#else context = FunRhs name' fixity' NoSrcStrict +#endif -- | Defines a function or value. -- @@ -203,6 +211,7 @@ patBindGRHSs p g = $ withPlaceHolder (withPlaceHolder (noExt PatBind (builtPat p) (noExt HsNoMultAnn) (mkGRHSs g))) +-- GHC913 (noExt PatBind (builtPat p) (HsUnannotated EpPatBind) (mkGRHSs g))) #elif MIN_VERSION_ghc(9,6,0) bindB $ withPlaceHolder @@ -328,7 +337,7 @@ stmt e = -- > bvar "x" <-- var "act" (<--) :: Pat' -> HsExpr' -> Stmt' #if MIN_VERSION_ghc(9,10,0) -p <-- e = withPlaceHolder $ BindStmt [] (builtPat p) (mkLocated e) +p <-- e = withPlaceHolder $ BindStmt noAnn (builtPat p) (mkLocated e) #elif MIN_VERSION_ghc(9,0,0) p <-- e = withPlaceHolder $ withEpAnnNotUsed BindStmt (builtPat p) (mkLocated e) #else diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index 0fbd71b..697df10 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -5,6 +5,7 @@ -- https://developers.google.com/open-source/licenses/bsd {-# LANGUAGE CPP #-} +{-# LANGUAGE TypeApplications #-} module GHC.SourceGen.Binds.Internal where #if MIN_VERSION_ghc(9,0,0) @@ -17,6 +18,7 @@ import GHC.Types.Basic ( Origin(Generated) #endif ) import GHC.Data.Bag (listToBag) +import GHC.Hs.Extension (GhcPs) #else import BasicTypes (Origin(Generated)) import Bag (listToBag) @@ -25,12 +27,17 @@ import GHC.Hs.Binds import GHC.Hs.Decls import GHC.Hs.Expr (MatchGroup(..), Match(..), GRHSs(..)) +import qualified Data.List.NonEmpty as NonEmpty + +import Language.Haskell.Syntax.Extension (XRec, wrapXRec, noExtField) + +import GHC.Types.SrcLoc (unLoc) #if !MIN_VERSION_ghc(8,6,0) import PlaceHolder (PlaceHolder(..)) #endif #if MIN_VERSION_ghc(9,10,0) -import GHC.Parser.Annotation (noAnn) +import GHC.Parser.Annotation (noAnn, emptyComments) #endif import GHC.SourceGen.Pat.Internal (parenthesize) @@ -52,7 +59,7 @@ valBinds vbs = #if MIN_VERSION_ghc(9,10,0) HsValBinds noAnn $ withNoAnnSortKey ValBinds - (listToBag $ map mkLocated binds) + (map mkLocated binds) (map mkLocated sigs) #elif MIN_VERSION_ghc(8,6,0) withEpAnnNotUsed HsValBinds @@ -118,11 +125,13 @@ matchGroup context matches = Generated #endif where + mkLPat :: [LPat'] -> XRec GhcPs [LPat' ] + mkLPat = wrapXRec @GhcPs matches' = mkLocated $ map (mkLocated . mkMatch) matches mkMatch :: RawMatch -> Match' LHsExpr' #if MIN_VERSION_ghc(9,10,0) - mkMatch r = Match [] context - (map builtPat $ map parenthesize $ rawMatchPats r) + mkMatch r = Match noExtField context + (mkLPat $ map (builtPat) $ map parenthesize $ rawMatchPats r) (mkGRHSs $ rawMatchGRHSs r) #else mkMatch r = withEpAnnNotUsed Match context @@ -132,7 +141,10 @@ matchGroup context matches = mkGRHSs :: RawGRHSs -> GRHSs' LHsExpr' mkGRHSs g = withEmptyEpAnnComments GRHSs -#if MIN_VERSION_ghc(9,4,0) +--mkGRHSs g = GRHSs emptyComments +#if MIN_VERSION_ghc(9,14,0) + (NonEmpty.fromList $ map mkLocated $ rawGRHSs g) +#elif MIN_VERSION_ghc(9,4,0) (map mkLocated $ rawGRHSs g) #else (map builtLoc $ rawGRHSs g) @@ -166,7 +178,6 @@ type GuardedExpr = GRHS' LHsExpr' class HasValBind t where sigB :: Sig' -> t bindB :: HsBind' -> t - instance HasValBind HsDecl' where sigB = noExt SigD bindB = noExt ValD diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 9546f2a..e5a657c 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -72,10 +72,11 @@ import BasicTypes (DerivStrategy(..)) #endif import GHC.Hs.Binds import GHC.Hs.Decls +import GHC.Parser.PostProcess (mkBangTy) import GHC.Hs.Type - ( ConDeclField(..) - , FieldOcc(..) + ( + FieldOcc(..) , HsConDetails(..) #if !MIN_VERSION_ghc(9,2,0) , HsImplicitBndrs (..) @@ -95,7 +96,6 @@ import GHC.Hs.Type , SrcStrictness(..) , SrcUnpackedness(..) #if MIN_VERSION_ghc(9,0,0) - , hsUnrestricted #endif ) @@ -185,7 +185,7 @@ class' context name vars decls = noExt TyClD $ ClassDecl { tcdCtxt = toHsContext $ mkLocated $ map mkLocated context #if MIN_VERSION_ghc(9,10,0) - , tcdCExt = ([], EpNoLayout, NoAnnSortKey) + , tcdCExt = (noAnn, EpNoLayout, NoAnnSortKey) #elif MIN_VERSION_ghc(9,6,0) , tcdLayout = NoLayoutInfo , tcdCExt = (EpAnnNotUsed, NoAnnSortKey) @@ -208,14 +208,14 @@ class' context name vars decls ] , tcdSigs = [mkLocated sig | ClassSig sig <- decls] , tcdMeths = - listToBag [mkLocated bind | ClassDefaultMethod bind <- decls] + [mkLocated bind | ClassDefaultMethod bind <- decls] , tcdATs = [] -- Associated types , tcdATDefs = [] -- Associated type defaults , tcdDocs = [] -- Haddocks } where #if MIN_VERSION_ghc(9,10,0) - funDep' = FunDep [] + funDep' = FunDep noAnn #elif MIN_VERSION_ghc(9,2,0) funDep' = withEpAnnNotUsed FunDep #else @@ -258,7 +258,7 @@ instance' :: HsType' -> [RawInstDecl] -> HsDecl' instance' ty decls = noExt InstD $ noExt ClsInstD $ ClsInstDecl { cid_poly_ty = sigType ty #if MIN_VERSION_ghc(9,10,0) - , cid_ext = (Nothing, [], NoAnnSortKey) + , cid_ext = (Nothing, noAnn, NoAnnSortKey) #elif MIN_VERSION_ghc(9,2,0) , cid_ext = (EpAnnNotUsed, NoAnnSortKey) #elif MIN_VERSION_ghc(8,10,0) @@ -266,7 +266,7 @@ instance' ty decls = noExt InstD $ noExt ClsInstD $ ClsInstDecl #elif MIN_VERSION_ghc(8,6,0) , cid_ext = NoExt #endif - , cid_binds = listToBag [mkLocated b | InstBind b <- decls] + , cid_binds = [mkLocated b | InstBind b <- decls] , cid_sigs = [mkLocated sig | InstSig sig <- decls] , cid_tyfam_insts = [mkLocated $ t | InstTyFam t <- decls] , cid_datafam_insts = [] @@ -295,14 +295,14 @@ tyFamInst :: HasTyFamInst t => RdrNameStr -> [HsType'] -> HsType' -> t tyFamInst name params ty = tyFamInstD $ tyFamInstDecl $ FamEqn - [] + noAnn (typeRdrName name) eqnBndrs (map (noExt HsValArg . mkLocated) params) Prefix (mkLocated ty) where - tyFamInstDecl = TyFamInstDecl [] + tyFamInstDecl = TyFamInstDecl noAnn eqnBndrs = noExt HsOuterImplicit #elif MIN_VERSION_ghc(9,2,0) tyFamInst name params ty = tyFamInstD @@ -353,7 +353,7 @@ tyFamInst name params ty = tyFamInstD type' :: OccNameStr -> [HsTyVarBndr'] -> HsType' -> HsDecl' type' name vars t = #if MIN_VERSION_ghc(9,10,0) - noExt TyClD $ withPlaceHolder $ SynDecl [] (typeRdrName $ unqual name) + noExt TyClD $ withPlaceHolder $ SynDecl noAnn (typeRdrName $ unqual name) (mkQTyVars vars) Prefix (mkLocated t) @@ -375,10 +375,10 @@ newOrDataType newOrData name vars conDecls derivs = noExt TyClD $ withPlaceHolder $ withPlaceHolder $ #if MIN_VERSION_ghc(9,6,0) #if MIN_VERSION_ghc(9,10,0) - DataDecl [] (typeRdrName $ unqual name) + noExt DataDecl (typeRdrName $ unqual name) (mkQTyVars vars) Prefix - $ noExt HsDataDefn + $ HsDataDefn noAnn Nothing Nothing Nothing @@ -465,10 +465,12 @@ data' = newOrDataType DataType -- > prefixCon "Foo" [field (var "a"), field (var "Int")] prefixCon :: OccNameStr -> [Field] -> ConDecl' prefixCon name fields = renderCon98Decl name +-- GHC913 $ prefixCon' $ map renderField fields $ prefixCon' $ map (hsUnrestricted . renderField) fields where #if MIN_VERSION_ghc(9,2,0) prefixCon' = PrefixCon [] +-- GHC913 prefixCon' = PrefixCon #else prefixCon' = PrefixCon #endif @@ -482,6 +484,7 @@ prefixCon name fields = renderCon98Decl name infixCon :: Field -> OccNameStr -> Field -> ConDecl' infixCon f name f' = renderCon98Decl name $ InfixCon (hsUnrestricted $ renderField f) (hsUnrestricted $ renderField f') +-- GHC913 $ InfixCon (renderField f) (renderField f') -- | Declares Haskell-98-style record constructor for a data or type -- declaration. @@ -495,7 +498,8 @@ recordCon name fields = renderCon98Decl name where mkLConDeclField (n, f) = #if MIN_VERSION_ghc(9,10,0) - mkLocated $ ConDeclField [] +-- GHC913 mkLocated $ noExt HsConDeclRecField + mkLocated $ ConDeclField noAnn [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n] #elif MIN_VERSION_ghc(9,4,0) mkLocated $ withEpAnnNotUsed ConDeclField @@ -506,6 +510,7 @@ recordCon name fields = renderCon98Decl name #endif (renderField f) Nothing +-- GHC913 --Nothing -- | An individual argument of a data constructor. Contains a type for the field, -- and whether the field is strict or lazy. @@ -546,15 +551,17 @@ hsUnrestricted :: a -> a hsUnrestricted = id #endif +--GHC913 renderField :: Field -> HsConDeclField GhcPs renderField :: Field -> LHsType GhcPs -- TODO: parenthesizeTypeForApp is an overestimate in the case of -- rendering an infix or record type. +--GHC913 renderField f = hsPlainTypeField $ wrap $ parenthesizeTypeForApp $ mkLocated $ fieldType f renderField f = wrap $ parenthesizeTypeForApp $ mkLocated $ fieldType f where wrap = case strictness f of NoSrcStrict -> id #if MIN_VERSION_ghc(9,10,0) - s -> mkLocated . (HsBangTy [] $ noSourceText HsSrcBang NoSrcUnpack s) + s -> mkLocated . mkBangTy noAnn s #else s -> mkLocated . (withEpAnnNotUsed HsBangTy $ noSourceText HsSrcBang NoSrcUnpack s) #endif @@ -564,7 +571,7 @@ renderCon98Decl name details = conDeclH98 (typeRdrName $ unqual name) False [] Nothing details Nothing where #if MIN_VERSION_ghc(9,10,0) - conDeclH98 = ConDeclH98 [] + conDeclH98 = ConDeclH98 noAnn #elif MIN_VERSION_ghc(9,2,0) conDeclH98 = withEpAnnNotUsed ConDeclH98 #elif MIN_VERSION_ghc(8,6,0) @@ -579,7 +586,7 @@ deriving' = derivingWay Nothing derivingWay :: Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause' derivingWay way ts = #if MIN_VERSION_ghc(9,10,0) - HsDerivingClause [] (fmap mkLocated way) $ mkLocated $ derivClauseTys $ map sigType ts + HsDerivingClause noAnn (fmap mkLocated way) $ mkLocated $ derivClauseTys $ map sigType ts #elif MIN_VERSION_ghc(9,4,0) withEpAnnNotUsed HsDerivingClause (fmap mkLocated way) $ mkLocated $ derivClauseTys $ map sigType ts #else @@ -597,7 +604,7 @@ derivingStock :: [HsType'] -> HsDerivingClause' derivingStock = derivingWay (Just strat) where #if MIN_VERSION_ghc(9,10,0) - strat = StockStrategy [] + strat = StockStrategy noAnn #elif MIN_VERSION_ghc(9,2,0) strat = withEpAnnNotUsed StockStrategy #else @@ -608,7 +615,7 @@ derivingNewtype :: [HsType'] -> HsDerivingClause' derivingNewtype = derivingWay (Just strat) where #if MIN_VERSION_ghc(9,10,0) - strat = NewtypeStrategy [] + strat = NewtypeStrategy noAnn #elif MIN_VERSION_ghc(9,2,0) strat = withEpAnnNotUsed NewtypeStrategy #else @@ -619,7 +626,7 @@ derivingAnyclass :: [HsType'] -> HsDerivingClause' derivingAnyclass = derivingWay (Just strat) where #if MIN_VERSION_ghc(9,10,0) - strat = AnyclassStrategy [] + strat = AnyclassStrategy noAnn #elif MIN_VERSION_ghc(9,2,0) strat = withEpAnnNotUsed AnyclassStrategy #else @@ -637,7 +644,7 @@ derivingVia :: HsType' -> [HsType'] -> HsDerivingClause' derivingVia t = derivingWay (Just $ strat $ sigType t) where #if MIN_VERSION_ghc(9,10,0) - strat = ViaStrategy . XViaStrategyPs [] + strat = ViaStrategy . XViaStrategyPs noAnn #elif MIN_VERSION_ghc(9,2,0) strat = ViaStrategy . withEpAnnNotUsed XViaStrategyPs #else @@ -652,7 +659,7 @@ standaloneDerivingStock :: HsType' -> HsDecl' standaloneDerivingStock = standaloneDerivingWay (Just strat) where #if MIN_VERSION_ghc(9,10,0) - strat = StockStrategy [] + strat = StockStrategy noAnn #elif MIN_VERSION_ghc(9,2,0) strat = withEpAnnNotUsed StockStrategy #else @@ -663,7 +670,7 @@ standaloneDerivingNewtype :: HsType' -> HsDecl' standaloneDerivingNewtype = standaloneDerivingWay (Just strat) where #if MIN_VERSION_ghc(9,10,0) - strat = NewtypeStrategy [] + strat = NewtypeStrategy noAnn #elif MIN_VERSION_ghc(9,2,0) strat = withEpAnnNotUsed NewtypeStrategy #else @@ -674,7 +681,7 @@ standaloneDerivingAnyclass :: HsType' -> HsDecl' standaloneDerivingAnyclass = standaloneDerivingWay (Just strat) where #if MIN_VERSION_ghc(9,10,0) - strat = AnyclassStrategy [] + strat = AnyclassStrategy noAnn #elif MIN_VERSION_ghc(9,2,0) strat = withEpAnnNotUsed AnyclassStrategy #else @@ -685,7 +692,7 @@ standaloneDerivingWay :: Maybe DerivStrategy' -> HsType' -> HsDecl' standaloneDerivingWay way ty = noExt DerivD derivDecl where derivDecl = #if MIN_VERSION_ghc(9,10,0) - DerivDecl (Nothing, []) (hsWC $ sigType ty) (fmap mkLocated way) Nothing + DerivDecl noAnn (hsWC $ sigType ty) (fmap mkLocated way) Nothing #elif MIN_VERSION_ghc(9,4,0) withEpAnnNotUsed DerivDecl (hsWC $ sigType ty) (fmap mkLocated way) Nothing #else @@ -731,13 +738,15 @@ patSynSig n = patSynSigs [n] patSynBind :: OccNameStr -> [OccNameStr] -> Pat' -> HsDecl' #if MIN_VERSION_ghc(9,10,0) patSynBind n ns p = bindB $ noExt PatSynBind - $ withPlaceHolder (PSB [] (valueRdrName $ unqual n)) + $ withPlaceHolder (PSB noAnn (valueRdrName $ unqual n)) (PrefixCon [] (map (valueRdrName . unqual) ns)) +-- GHC913 (PrefixCon (map (valueRdrName . unqual) ns)) (builtPat p) ImplicitBidirectional #else patSynBind n ns p = bindB $ noExt PatSynBind $ withPlaceHolder (withEpAnnNotUsed PSB (valueRdrName $ unqual n)) + (prefixCon' (map (valueRdrName . unqual) ns)) (prefixCon' (map (valueRdrName . unqual) ns)) (builtPat p) ImplicitBidirectional diff --git a/src/GHC/SourceGen/Expr.hs b/src/GHC/SourceGen/Expr.hs index 9fd8992..65f1f5a 100644 --- a/src/GHC/SourceGen/Expr.hs +++ b/src/GHC/SourceGen/Expr.hs @@ -31,6 +31,7 @@ module GHC.SourceGen.Expr import GHC.Hs.Expr import GHC.Hs.Extension (GhcPs) #if MIN_VERSION_ghc(9,10,0) +import Control.Monad (mzero) import GHC.Hs.Expr (EpAnnHsCase (..)) import GHC.Parser.Annotation (EpToken(..), noAnn, noSpanAnchor) import GHC.Types.SourceText (SourceText(NoSourceText)) @@ -43,7 +44,12 @@ import GHC.Hs.Pat (HsFieldBind(..), HsRecFields(..)) #else import GHC.Hs.Pat (HsRecField'(..), HsRecFields(..)) #endif -import GHC.Hs.Type (FieldOcc(..), AmbiguousFieldOcc(..)) +import GHC.Hs.Type ( + FieldOcc(..) +#if !MIN_VERSION_ghc(9,12,0) + , AmbiguousFieldOcc(..) +#endif + ) import GHC.Hs.Utils (mkHsIf) import Data.String (fromString) #if MIN_VERSION_ghc(9,0,0) @@ -56,6 +62,7 @@ import SrcLoc (unLoc, GenLocated(..)) import GHC.Parser.Annotation (EpAnn(..)) #endif +-- GHC913 import qualified Data.List.NonEmpty as NonEmpty import GHC.SourceGen.Binds.Internal import GHC.SourceGen.Binds import GHC.SourceGen.Expr.Internal @@ -76,7 +83,7 @@ overLabel :: String -> HsExpr' overLabel = hsOverLabel . fromString where #if MIN_VERSION_ghc(9,10,0) - hsOverLabel = noExt HsOverLabel NoSourceText + hsOverLabel = HsOverLabel NoSourceText #elif MIN_VERSION_ghc(9,6,0) hsOverLabel = withEpAnnNotUsed HsOverLabel NoSourceText #elif MIN_VERSION_ghc(9,2,0) @@ -105,7 +112,7 @@ case' :: HsExpr' -> [RawMatch] -> HsExpr' case' e matches = HsCase ann (mkLocated e) $ matchGroup CaseAlt matches where - ann = EpAnnHsCase noSpanAnchor noSpanAnchor [] + ann = EpAnnHsCase noAnn noAnn #else case' e matches = withEpAnnNotUsed HsCase (mkLocated e) $ matchGroup CaseAlt matches @@ -113,14 +120,14 @@ case' e matches = withEpAnnNotUsed HsCase (mkLocated e) lambda :: [Pat'] -> HsExpr' -> HsExpr' #if MIN_VERSION_ghc(9,10,0) -lambda ps e = HsLam [] LamSingle $ matchGroup (LamAlt LamSingle) [match ps e] +lambda ps e = HsLam noAnn LamSingle $ matchGroup (LamAlt LamSingle) [match ps e] #else lambda ps e = noExt HsLam $ matchGroup LambdaExpr [match ps e] #endif lambdaCase :: [RawMatch] -> HsExpr' #if MIN_VERSION_ghc(9,10,0) -lambdaCase = HsLam [] LamCase . matchGroup CaseAlt +lambdaCase = HsLam noAnn LamCase . matchGroup CaseAlt #elif MIN_VERSION_ghc(9,4,0) lambdaCase = withEpAnnNotUsed HsLamCase LamCase . matchGroup CaseAlt #else @@ -152,7 +159,8 @@ if' x y z = mkHsIf -- > ] multiIf :: [GuardedExpr] -> HsExpr' #if MIN_VERSION_ghc(9,10,0) -multiIf = withPlaceHolder (HsMultiIf []) . map mkLocated +multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . map mkLocated +-- GHC913 multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . NonEmpty.fromList . map mkLocated #elif MIN_VERSION_ghc(9,4,0) multiIf = withPlaceHolder (withEpAnnNotUsed HsMultiIf) . map mkLocated #else @@ -223,7 +231,7 @@ listComp lastExpr stmts = -- > var "e" @::@ var "t" (@::@) :: HsExpr' -> HsType' -> HsExpr' #if MIN_VERSION_ghc(9,10,0) -e @::@ t = ExprWithTySig [] (mkLocated e) (sigWcType t) +e @::@ t = ExprWithTySig noAnn (mkLocated e) (sigWcType t) #elif MIN_VERSION_ghc(8,8,0) e @::@ t = withEpAnnNotUsed ExprWithTySig (mkLocated e) (sigWcType t) #elif MIN_VERSION_ghc(8,6,0) @@ -263,14 +271,14 @@ tyApp e t = HsAppType e' t' -- > recordConE "A" [("x", var "y")] recordConE :: RdrNameStr -> [(RdrNameStr, HsExpr')] -> HsExpr' #if MIN_VERSION_ghc(9,10,0) -recordConE c fs = (withPlaceHolder $ RecordCon [] (valueRdrName c)) +recordConE c fs = (withPlaceHolder $ RecordCon noAnn (valueRdrName c)) #else recordConE c fs = (withPlaceHolder $ withEpAnnNotUsed RecordCon (valueRdrName c)) #endif #if !MIN_VERSION_ghc(8,6,0) noPostTcExpr #endif - $ HsRecFields (map recField fs) + $ noExt HsRecFields (map recField fs) Nothing -- No ".." where recField :: (RdrNameStr, HsExpr') -> LHsRecField' LHsExpr' @@ -281,7 +289,7 @@ recordConE c fs = (withPlaceHolder $ withEpAnnNotUsed RecordCon (valueRdrName c) mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f , hfbRHS = mkLocated e , hfbPun = False - , hfbAnn = [] + , hfbAnn = mzero #elif MIN_VERSION_ghc(9,4,0) mkLocated HsFieldBind { hfbLHS = @@ -318,7 +326,7 @@ recordUpd :: HsExpr' -> [(RdrNameStr, HsExpr')] -> HsExpr' recordUpd e fs = #if MIN_VERSION_ghc(9,10,0) withPlaceHolder4 - $ RecordUpd [] (parenthesizeExprForApp $ mkLocated e) + $ RecordUpd noAnn (parenthesizeExprForApp $ mkLocated e) $ toRecordUpdFields $ map mkField fs #else withPlaceHolder4 @@ -331,10 +339,10 @@ recordUpd e fs = #if MIN_VERSION_ghc(9,10,0) mkLocated HsFieldBind { hfbLHS = - mkLocated $ withPlaceHolder $ noExt Ambiguous $ valueRdrName f + mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f , hfbRHS = mkLocated e' , hfbPun = False - , hfbAnn = [] + , hfbAnn = mzero #elif MIN_VERSION_ghc(9,4,0) mkLocated HsFieldBind { hfbLHS = @@ -366,7 +374,7 @@ recordUpd e fs = arithSeq :: ArithSeqInfo GhcPs -> HsExpr' arithSeq = #if MIN_VERSION_ghc(9,10,0) - ArithSeq [] Nothing + ArithSeq noAnn Nothing #elif MIN_VERSION_ghc(8,6,0) withEpAnnNotUsed ArithSeq Nothing #else diff --git a/src/GHC/SourceGen/Lit.hs b/src/GHC/SourceGen/Lit.hs index 94635ae..8cd2a4c 100644 --- a/src/GHC/SourceGen/Lit.hs +++ b/src/GHC/SourceGen/Lit.hs @@ -31,6 +31,7 @@ import GHC.Hs.Lit import GHC.Hs.Expr (noExpr, noSyntaxExpr, HsExpr(..)) import GHC.Hs.Pat (Pat(..)) +import GHC.Parser.Annotation (EpLayout (..), noAnn) import GHC.SourceGen.Lit.Internal import GHC.SourceGen.Syntax.Internal @@ -51,7 +52,7 @@ instance HasLit Pat' where lit = noExt LitPat #if MIN_VERSION_ghc(9,10,0) overLit l = withPlaceHolder - $ NPat [] (mkLocated l) Nothing noSyntaxExpr + $ NPat noAnn (mkLocated l) Nothing noSyntaxExpr #elif MIN_VERSION_ghc(9,4,0) overLit l = withPlaceHolder $ withEpAnnNotUsed NPat (mkLocated l) Nothing noSyntaxExpr diff --git a/src/GHC/SourceGen/Module.hs b/src/GHC/SourceGen/Module.hs index 513b5da..62724c4 100644 --- a/src/GHC/SourceGen/Module.hs +++ b/src/GHC/SourceGen/Module.hs @@ -47,7 +47,7 @@ import GHC.Hs , LayoutInfo (NoLayoutInfo) #endif #if MIN_VERSION_ghc(9,6,0) - , hsmodDeprecMessage, hsmodHaddockModHeader, hsmodAnn, AnnKeywordId, XModulePs (XModulePs, hsmodLayout), noAnn, GhcPs, XImportDeclPass (XImportDeclPass, ideclAnn), SrcSpanAnnA, noExtField + , hsmodDeprecMessage, hsmodHaddockModHeader, hsmodAnn, XModulePs (XModulePs, hsmodLayout), noAnn, GhcPs, XImportDeclPass (XImportDeclPass, ideclAnn), SrcSpanAnnA, noExtField #endif ) #if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) @@ -195,7 +195,7 @@ source d = d { ideclSource = -- > thingAll "A" thingAll :: RdrNameStr -> IE' #if MIN_VERSION_ghc(9,10,0) -thingAll n = IEThingAll (Nothing, []) (wrappedName n) Nothing +thingAll n = IEThingAll noAnn (wrappedName n) Nothing #else thingAll = withEpAnnNotUsed' IEThingAll . wrappedName #endif @@ -207,7 +207,7 @@ thingAll = withEpAnnNotUsed' IEThingAll . wrappedName -- > thingWith "A" ["b", "C"] thingWith :: RdrNameStr -> [OccNameStr] -> IE' #if MIN_VERSION_ghc(9,10,0) -thingWith n cs = IEThingWith (Nothing, []) (wrappedName n) NoIEWildcard (map (wrappedName . unqual) cs) Nothing +thingWith n cs = IEThingWith noAnn (wrappedName n) NoIEWildcard (map (wrappedName . unqual) cs) Nothing #else thingWith n cs = withEpAnnNotUsed' IEThingWith (wrappedName n) NoIEWildcard (map (wrappedName . unqual) cs) @@ -237,7 +237,7 @@ wrappedName = mkLocated . IEName . exportRdrName -- > moduleContents "M" moduleContents :: ModuleNameStr -> IE' #if MIN_VERSION_ghc(9,10,0) -moduleContents n = IEModuleContents (Nothing, []) (mkLocated (unModuleNameStr n)) +moduleContents n = IEModuleContents noAnn (mkLocated (unModuleNameStr n)) #else moduleContents = withEpAnnNotUsed' IEModuleContents . mkLocated . unModuleNameStr #endif diff --git a/src/GHC/SourceGen/Overloaded.hs b/src/GHC/SourceGen/Overloaded.hs index 5794c3e..b351f72 100644 --- a/src/GHC/SourceGen/Overloaded.hs +++ b/src/GHC/SourceGen/Overloaded.hs @@ -21,6 +21,8 @@ module GHC.SourceGen.Overloaded import GHC.Hs.Type ( HsType(..) , HsTyVarBndr(..) + , HsBndrVar(HsBndrVar) + , HsBndrKind(HsBndrNoKind) #if MIN_VERSION_ghc(9,8,0) , HsBndrVis (HsBndrRequired) #endif @@ -45,7 +47,7 @@ import GHC.Hs #endif ) #if MIN_VERSION_ghc(9,10,0) -import GHC.Parser.Annotation (AnnList (..), AnnParen (AnnParen), ParenType (AnnParens), noAnn) +import GHC.Parser.Annotation (AnnList (..), noAnn) #endif #if MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic (Boxity(..)) @@ -94,7 +96,7 @@ instance Par Pat' where instance Par HsType' where #if MIN_VERSION_ghc(9,10,0) - par = HsParTy (AnnParen AnnParens noSpanAnchor noSpanAnchor) . mkLocated + par = HsParTy noAnn . mkLocated #else par = withEpAnnNotUsed HsParTy . mkLocated #endif @@ -163,7 +165,7 @@ infixl 2 @@ instance App HsExpr' where #if MIN_VERSION_ghc(9,10,0) op x o y - = OpApp [] + = noExt OpApp (parenthesizeExprForOp $ mkLocated x) (mkLocated $ var o) (parenthesizeExprForOp $ mkLocated y) @@ -188,7 +190,7 @@ instance App HsExpr' where instance App HsType' where op x o y #if MIN_VERSION_ghc(9,10,0) - = HsOpTy [] notPromoted (parenthesizeTypeForOp $ mkLocated x) + = noExt HsOpTy notPromoted (parenthesizeTypeForOp $ mkLocated x) (typeRdrName o) (parenthesizeTypeForOp $ mkLocated y) #elif MIN_VERSION_ghc(9,4,0) @@ -216,7 +218,7 @@ instance HasTuple HsExpr' where #if MIN_VERSION_ghc(9,10,0) tupleOf b ts = - ExplicitTuple [] (map (noExt Present . mkLocated) ts) b + ExplicitTuple noAnn (map (noExt Present . mkLocated) ts) b #else tupleOf b ts = explicitTuple @@ -236,7 +238,7 @@ unitDataConName = mkLocated $ nameRdrName $ dataConName $ unitDataCon instance HasTuple HsType' where #if MIN_VERSION_ghc(9,10,0) - tupleOf b = HsTupleTy (AnnParen AnnParens noSpanAnchor noSpanAnchor) b' . map mkLocated + tupleOf b = HsTupleTy noAnn b' . map mkLocated #else tupleOf b = withEpAnnNotUsed HsTupleTy b' . map mkLocated #endif @@ -251,7 +253,7 @@ instance HasTuple HsType' where instance HasTuple Pat' where tupleOf b ps = #if MIN_VERSION_ghc(9,10,0) - TuplePat [] (map builtPat ps) b + TuplePat noAnn (map builtPat ps) b #elif MIN_VERSION_ghc(8,6,0) withEpAnnNotUsed TuplePat (map builtPat ps) b #else @@ -331,7 +333,7 @@ instance BVar HsExpr' where instance Var HsType' where #if MIN_VERSION_ghc(9,10,0) - var = HsTyVar [] notPromoted . typeRdrName + var = HsTyVar noAnn notPromoted . typeRdrName #else var = withEpAnnNotUsed HsTyVar notPromoted . typeRdrName #endif @@ -341,9 +343,11 @@ instance BVar HsType' where #if MIN_VERSION_ghc(9,10,0) instance BVar HsTyVarBndr' where - bvar = UserTyVar [] (noExt HsBndrRequired) . typeRdrName . UnqualStr + bvar n = HsTvb noAnn (noExt HsBndrRequired) (noExt HsBndrVar $ typeRdrName $ UnqualStr n) (noExt HsBndrNoKind) + --bvar = UserTyVar noAnn (noExt HsBndrRequired) . typeRdrName . UnqualStr instance BVar HsTyVarBndrS' where - bvar = UserTyVar [] SpecifiedSpec . typeRdrName . UnqualStr + bvar n = HsTvb noAnn SpecifiedSpec (noExt HsBndrVar $ typeRdrName $ UnqualStr n) (noExt HsBndrNoKind) + --bvar = UserTyVar noAnn SpecifiedSpec . typeRdrName . UnqualStr #elif MIN_VERSION_ghc(9,8,0) instance BVar HsTyVarBndr' where bvar = withEpAnnNotUsed UserTyVar HsBndrRequired . typeRdrName . UnqualStr diff --git a/src/GHC/SourceGen/Pat.hs b/src/GHC/SourceGen/Pat.hs index 166a910..4021f11 100644 --- a/src/GHC/SourceGen/Pat.hs +++ b/src/GHC/SourceGen/Pat.hs @@ -64,16 +64,16 @@ v `asP` p = -- > ===== -- > conP "A" [bvar "b", bvar "c"] conP :: RdrNameStr -> [Pat'] -> Pat' -conP c = conPat (valueRdrName c) . prefixCon . map (builtPat . parenthesize) +conP c pats = conPat (valueRdrName c) (prefixCon (map (builtPat . parenthesize) pats)) where #if MIN_VERSION_ghc(9,10,0) - conPat = ConPat [] + conPat = ConPat noAnn #elif MIN_VERSION_ghc(9,0,0) conPat = withEpAnnNotUsed ConPat #else conPat = ConPatIn #endif -#if MIN_VERSION_ghc(9,2,0) +#if !MIN_VERSION_ghc(9,13,0) && MIN_VERSION_ghc(9,2,0) prefixCon = PrefixCon [] #else prefixCon = PrefixCon @@ -90,14 +90,14 @@ conP_ c = conP c [] recordConP :: RdrNameStr -> [(RdrNameStr, Pat')] -> Pat' recordConP c fs = #if MIN_VERSION_ghc(9,10,0) - ConPat [] + ConPat noAnn #elif MIN_VERSION_ghc(9,0,0) withEpAnnNotUsed ConPat #else ConPatIn #endif (valueRdrName c) - $ RecCon $ HsRecFields (map mkRecField fs) Nothing -- No ".." + $ RecCon $ noExt HsRecFields (map mkRecField fs) Nothing -- No ".." where mkRecField :: (RdrNameStr, Pat') -> LHsRecField' LPat' mkRecField (f, p) = @@ -132,7 +132,7 @@ recordConP c fs = -- > strictP (bvar x) strictP :: Pat' -> Pat' #if MIN_VERSION_ghc(9,10,0) -strictP = BangPat [] . builtPat . parenthesize +strictP = BangPat noAnn . builtPat . parenthesize #else strictP = withEpAnnNotUsed BangPat . builtPat . parenthesize #endif @@ -144,7 +144,7 @@ strictP = withEpAnnNotUsed BangPat . builtPat . parenthesize -- > lazyP (conP "A" [bvar x]) lazyP :: Pat' -> Pat' #if MIN_VERSION_ghc(9,10,0) -lazyP = LazyPat [] . builtPat . parenthesize +lazyP = LazyPat noAnn . builtPat . parenthesize #else lazyP = withEpAnnNotUsed LazyPat . builtPat . parenthesize #endif @@ -156,7 +156,7 @@ lazyP = withEpAnnNotUsed LazyPat . builtPat . parenthesize -- > sigPat (bvar "x") (var "y") sigP :: Pat' -> HsType' -> Pat' #if MIN_VERSION_ghc(9,10,0) -sigP p t = SigPat [] (builtPat p) (patSigType t) +sigP p t = SigPat noAnn (builtPat p) (patSigType t) #elif MIN_VERSION_ghc(8,8,0) sigP p t = withEpAnnNotUsed SigPat (builtPat p) (patSigType t) #elif MIN_VERSION_ghc(8,6,0) diff --git a/src/GHC/SourceGen/Pat/Internal.hs b/src/GHC/SourceGen/Pat/Internal.hs index ce62a1c..37a18e8 100644 --- a/src/GHC/SourceGen/Pat/Internal.hs +++ b/src/GHC/SourceGen/Pat/Internal.hs @@ -32,7 +32,9 @@ needsPar (NPat _ l _ _) = overLitNeedsParen $ unLoc l needsPar (LitPat l) = litNeedsParen l needsPar (NPat l _ _ _) = overLitNeedsParen $ unLoc l #endif -#if MIN_VERSION_ghc(9,2,0) +#if MIN_VERSION_ghc(9,14,0) +needsPar (ConPat _ _ (PrefixCon xs)) = not $ null xs +#elif MIN_VERSION_ghc(9,2,0) needsPar (ConPat _ _ (PrefixCon _ xs)) = not $ null xs #elif MIN_VERSION_ghc(9,0,0) needsPar (ConPat _ _ (PrefixCon xs)) = not $ null xs diff --git a/src/GHC/SourceGen/Type.hs b/src/GHC/SourceGen/Type.hs index 40d854e..901f2a2 100644 --- a/src/GHC/SourceGen/Type.hs +++ b/src/GHC/SourceGen/Type.hs @@ -29,6 +29,7 @@ import GHC.Parser.Annotation import GHC.Hs.Type #endif +import Language.Haskell.Syntax.Type #if MIN_VERSION_ghc(9,4,0) import Language.Haskell.Syntax.Extension #endif @@ -41,7 +42,7 @@ import GHC.SourceGen.Type.Internal -- | A promoted name, for example from the @DataKinds@ extension. tyPromotedVar :: RdrNameStr -> HsType' #if MIN_VERSION_ghc(9,10,0) -tyPromotedVar = HsTyVar [] promoted . typeRdrName +tyPromotedVar = HsTyVar noAnn promoted . typeRdrName #else tyPromotedVar = withEpAnnNotUsed HsTyVar promoted . typeRdrName #endif @@ -54,7 +55,7 @@ numTy = noExt HsTyLit . noSourceText HsNumTy listTy :: HsType' -> HsType' #if MIN_VERSION_ghc(9,10,0) -listTy = HsListTy (AnnParen AnnParens noSpanAnchor noSpanAnchor) . mkLocated +listTy = HsListTy noAnn . mkLocated #else listTy = withEpAnnNotUsed HsListTy . mkLocated #endif @@ -63,14 +64,14 @@ listPromotedTy :: [HsType'] -> HsType' -- Lists of two or more elements don't need the explicit tick (`'`). -- But for consistency, just always add it. #if MIN_VERSION_ghc(9,10,0) -listPromotedTy = withPlaceHolder (HsExplicitListTy [] promoted) . map mkLocated +listPromotedTy = withPlaceHolder (HsExplicitListTy noAnn promoted) . map mkLocated #else listPromotedTy = withPlaceHolder (withEpAnnNotUsed HsExplicitListTy promoted) . map mkLocated #endif tuplePromotedTy :: [HsType'] -> HsType' #if MIN_VERSION_ghc(9,10,0) -tuplePromotedTy = withPlaceHolders (withEpAnnNotUsed (HsExplicitTupleTy [])) . map mkLocated +tuplePromotedTy = withPlaceHolders (HsExplicitTupleTy noAnn IsPromoted) . map mkLocated #else tuplePromotedTy = withPlaceHolders (withEpAnnNotUsed HsExplicitTupleTy) . map mkLocated #endif @@ -84,6 +85,7 @@ tuplePromotedTy = withPlaceHolders (withEpAnnNotUsed HsExplicitTupleTy) . map mk a --> b = #if MIN_VERSION_ghc(9,10,0) (noExt HsFunTy) + --(HsUnannotated (EpArrow (EpUniTok noSpanAnchor NormalSyntax))) (HsUnrestrictedArrow (EpUniTok noSpanAnchor NormalSyntax)) (parenthesizeTypeForFun $ mkLocated a) (mkLocated b) #elif MIN_VERSION_ghc(9,4,0) @@ -157,10 +159,11 @@ infixr 0 ==> kindedVar :: OccNameStr -> HsType' -> HsTyVarBndr' kindedVar v t = #if MIN_VERSION_ghc(9,10,0) - KindedTyVar - [] - (noExt HsBndrRequired) - (typeRdrName $ UnqualStr v) (mkLocated t) + HsTvb noAnn (noExt HsBndrRequired) (noExt HsBndrVar $ typeRdrName $ UnqualStr v) (noExt HsBndrKind $ mkLocated t) + -- KindedTyVar + -- [] + -- (noExt HsBndrRequired) + -- (typeRdrName $ UnqualStr v) (mkLocated t) #elif MIN_VERSION_ghc(9,8,0) withEpAnnNotUsed KindedTyVar HsBndrRequired diff --git a/src/GHC/SourceGen/Type/Internal.hs b/src/GHC/SourceGen/Type/Internal.hs index 9c9a95f..3f53537 100644 --- a/src/GHC/SourceGen/Type/Internal.hs +++ b/src/GHC/SourceGen/Type/Internal.hs @@ -18,7 +18,7 @@ import SrcLoc (unLoc) #endif #if MIN_VERSION_ghc(9,10,0) -import GHC.Parser.Annotation (AnnParen (AnnParen), ParenType (AnnParens), noAnn, noSpanAnchor) +import GHC.Parser.Annotation (AnnParen, noAnn, noSpanAnchor) #endif import GHC.SourceGen.Syntax.Internal @@ -68,7 +68,7 @@ needsParenForApp t = case t of parTy :: LHsType GhcPs -> LHsType GhcPs #if MIN_VERSION_ghc(9,10,0) -parTy = mkLocated . HsParTy (AnnParen AnnParens noSpanAnchor noSpanAnchor) +parTy = mkLocated . HsParTy noAnn #else parTy = mkLocated . withEpAnnNotUsed HsParTy #endif From 2d679e4af806eef6f61e07ccdc71a53714da5a69 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 14:06:06 +0200 Subject: [PATCH 03/12] Use lts-24.6 for GHC 9.10 --- stack-9.10.yaml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/stack-9.10.yaml b/stack-9.10.yaml index 201009a..65962c6 100644 --- a/stack-9.10.yaml +++ b/stack-9.10.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-2024-10-27 -compiler: ghc-9.10.1 +resolver: lts-24.6 +compiler: ghc-9.10.2 packages: - . @@ -15,12 +15,3 @@ ghc-options: "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports allow-newer: true - -extra-deps: -- Cabal-3.12.0.0 -- Cabal-syntax-3.12.0.0 -- directory-1.3.8.3 -- filepath-1.5.2.0 -- os-string-2.0.2 -- process-1.6.19.0 -- unix-2.8.5.1 From b1ebed19a4a5dde2f58c2af929366ea6dda82d29 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 15:02:26 +0200 Subject: [PATCH 04/12] Bump version bounds for GHC 9.12 --- ghc-source-gen.cabal | 14 +++++++------- package.yaml | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ghc-source-gen.cabal b/ghc-source-gen.cabal index 789bda1..a024561 100644 --- a/ghc-source-gen.cabal +++ b/ghc-source-gen.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0. +-- This file has been generated from package.yaml by hpack version 0.38.0. -- -- see: https://github.com/sol/hpack @@ -61,7 +61,7 @@ library TypeSynonymInstances build-depends: base >=4.7 && <5 - , ghc >=8.4 && <9.11 + , ghc >=8.4 && <9.13 default-language: Haskell2010 if impl(ghc<8.10) other-modules: @@ -102,13 +102,13 @@ test-suite name_test FlexibleInstances TypeSynonymInstances build-depends: - QuickCheck >=2.10 && <2.15 + QuickCheck >=2.10 && <2.17 , base >=4.7 && <5 - , ghc >=8.4 && <9.11 + , ghc >=8.4 && <9.13 , ghc-source-gen , tasty >=1.0 && <1.6 , tasty-hunit ==0.10.* - , tasty-quickcheck >=0.9 && <0.11 + , tasty-quickcheck >=0.9 && <0.12 default-language: Haskell2010 test-suite pprint_examples @@ -125,7 +125,7 @@ test-suite pprint_examples TypeSynonymInstances build-depends: base >=4.7 && <5 - , ghc >=8.4 && <9.11 + , ghc >=8.4 && <9.13 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.6 @@ -151,7 +151,7 @@ test-suite pprint_test TypeSynonymInstances build-depends: base >=4.7 && <5 - , ghc >=8.4 && <9.11 + , ghc >=8.4 && <9.13 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.6 diff --git a/package.yaml b/package.yaml index 21b2492..ab511d0 100644 --- a/package.yaml +++ b/package.yaml @@ -30,7 +30,7 @@ description: | dependencies: - base >= 4.7 && < 5 -- ghc >= 8.4 && < 9.11 +- ghc >= 8.4 && < 9.13 default-extensions: - DataKinds @@ -116,7 +116,7 @@ tests: source-dirs: tests dependencies: - ghc-source-gen - - QuickCheck >= 2.10 && < 2.15 + - QuickCheck >= 2.10 && < 2.17 - tasty >= 1.0 && < 1.6 - tasty-hunit == 0.10.* - - tasty-quickcheck >= 0.9 && < 0.11 + - tasty-quickcheck >= 0.9 && < 0.12 From 5ee69b514da6ced78ddfe30cf57f8c890b57c1b6 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 15:28:05 +0200 Subject: [PATCH 05/12] Works with GHC 9.10 again --- src/GHC/SourceGen/Binds/Internal.hs | 16 +++++++++++----- src/GHC/SourceGen/Decl.hs | 20 +++++++++++++++++++- src/GHC/SourceGen/Expr.hs | 23 ++++++++++++++++++++--- src/GHC/SourceGen/Overloaded.hs | 27 ++++++++++++++++----------- src/GHC/SourceGen/Pat.hs | 4 ++++ src/GHC/SourceGen/Type.hs | 19 ++++++++++++------- 6 files changed, 82 insertions(+), 27 deletions(-) diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index 697df10..a8ef9f3 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -59,7 +59,11 @@ valBinds vbs = #if MIN_VERSION_ghc(9,10,0) HsValBinds noAnn $ withNoAnnSortKey ValBinds +# if MIN_VERSION_ghc(9,12,0) (map mkLocated binds) +# else + (listToBag $ map mkLocated binds) +# endif (map mkLocated sigs) #elif MIN_VERSION_ghc(8,6,0) withEpAnnNotUsed HsValBinds @@ -125,19 +129,21 @@ matchGroup context matches = Generated #endif where - mkLPat :: [LPat'] -> XRec GhcPs [LPat' ] - mkLPat = wrapXRec @GhcPs matches' = mkLocated $ map (mkLocated . mkMatch) matches mkMatch :: RawMatch -> Match' LHsExpr' #if MIN_VERSION_ghc(9,10,0) +# if MIN_VERSION_ghc(9,12,0) mkMatch r = Match noExtField context - (mkLPat $ map (builtPat) $ map parenthesize $ rawMatchPats r) - (mkGRHSs $ rawMatchGRHSs r) + (wrapXRec @GhcPs $ map builtPat $ map parenthesize $ rawMatchPats r) +# else + mkMatch r = Match noAnn context + (map builtPat $ map parenthesize $ rawMatchPats r) +# endif #else mkMatch r = withEpAnnNotUsed Match context (map builtPat $ map parenthesize $ rawMatchPats r) - (mkGRHSs $ rawMatchGRHSs r) #endif + (mkGRHSs $ rawMatchGRHSs r) mkGRHSs :: RawGRHSs -> GRHSs' LHsExpr' mkGRHSs g = withEmptyEpAnnComments GRHSs diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index e5a657c..9806717 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -208,7 +208,11 @@ class' context name vars decls ] , tcdSigs = [mkLocated sig | ClassSig sig <- decls] , tcdMeths = +#if MIN_VERSION_ghc(9,12,0) [mkLocated bind | ClassDefaultMethod bind <- decls] +#else + listToBag [mkLocated bind | ClassDefaultMethod bind <- decls] +#endif , tcdATs = [] -- Associated types , tcdATDefs = [] -- Associated type defaults , tcdDocs = [] -- Haddocks @@ -266,7 +270,11 @@ instance' ty decls = noExt InstD $ noExt ClsInstD $ ClsInstDecl #elif MIN_VERSION_ghc(8,6,0) , cid_ext = NoExt #endif +#if MIN_VERSION_ghc(9,12,0) , cid_binds = [mkLocated b | InstBind b <- decls] +#else + , cid_binds = listToBag [mkLocated b | InstBind b <- decls] +#endif , cid_sigs = [mkLocated sig | InstSig sig <- decls] , cid_tyfam_insts = [mkLocated $ t | InstTyFam t <- decls] , cid_datafam_insts = [] @@ -374,7 +382,7 @@ newOrDataType newOrDataType newOrData name vars conDecls derivs = noExt TyClD $ withPlaceHolder $ withPlaceHolder $ #if MIN_VERSION_ghc(9,6,0) -#if MIN_VERSION_ghc(9,10,0) +#if MIN_VERSION_ghc(9,12,0) noExt DataDecl (typeRdrName $ unqual name) (mkQTyVars vars) Prefix @@ -384,6 +392,16 @@ newOrDataType newOrData name vars conDecls derivs Nothing (mkDataDefnCon newOrData conDecls) (map mkLocated derivs) +#elif MIN_VERSION_ghc(9,10,0) + DataDecl [] (typeRdrName $ unqual name) + (mkQTyVars vars) + Prefix + $ noExt HsDataDefn + Nothing + Nothing + Nothing + (mkDataDefnCon newOrData conDecls) + (map mkLocated derivs) #else withEpAnnNotUsed DataDecl (typeRdrName $ unqual name) (mkQTyVars vars) diff --git a/src/GHC/SourceGen/Expr.hs b/src/GHC/SourceGen/Expr.hs index 65f1f5a..126acf4 100644 --- a/src/GHC/SourceGen/Expr.hs +++ b/src/GHC/SourceGen/Expr.hs @@ -82,8 +82,10 @@ import GHC.SourceGen.Type.Internal overLabel :: String -> HsExpr' overLabel = hsOverLabel . fromString where -#if MIN_VERSION_ghc(9,10,0) +#if MIN_VERSION_ghc(9,12,0) hsOverLabel = HsOverLabel NoSourceText +#elif MIN_VERSION_ghc(9,10,0) + hsOverLabel = noExt HsOverLabel NoSourceText #elif MIN_VERSION_ghc(9,6,0) hsOverLabel = withEpAnnNotUsed HsOverLabel NoSourceText #elif MIN_VERSION_ghc(9,2,0) @@ -112,7 +114,11 @@ case' :: HsExpr' -> [RawMatch] -> HsExpr' case' e matches = HsCase ann (mkLocated e) $ matchGroup CaseAlt matches where +# if MIN_VERSION_ghc(9,12,0) ann = EpAnnHsCase noAnn noAnn +# elif MIN_VERSION_ghc(9,10,0) + ann = EpAnnHsCase noAnn noAnn [] +# endif #else case' e matches = withEpAnnNotUsed HsCase (mkLocated e) $ matchGroup CaseAlt matches @@ -158,8 +164,10 @@ if' x y z = mkHsIf -- > , guardedStmt (var "otherwise") $ rhs (string "h") -- > ] multiIf :: [GuardedExpr] -> HsExpr' -#if MIN_VERSION_ghc(9,10,0) +#if MIN_VERSION_ghc(9,12,0) multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . map mkLocated +#elif MIN_VERSION_ghc(9,10,0) +multiIf = withPlaceHolder (HsMultiIf []) . map mkLocated -- GHC913 multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . NonEmpty.fromList . map mkLocated #elif MIN_VERSION_ghc(9,4,0) multiIf = withPlaceHolder (withEpAnnNotUsed HsMultiIf) . map mkLocated @@ -278,7 +286,12 @@ recordConE c fs = (withPlaceHolder $ withEpAnnNotUsed RecordCon (valueRdrName c) #if !MIN_VERSION_ghc(8,6,0) noPostTcExpr #endif - $ noExt HsRecFields (map recField fs) +#if MIN_VERSION_ghc(9,12,0) + $ noExt HsRecFields +#else + $ HsRecFields +#endif + (map recField fs) Nothing -- No ".." where recField :: (RdrNameStr, HsExpr') -> LHsRecField' LHsExpr' @@ -339,7 +352,11 @@ recordUpd e fs = #if MIN_VERSION_ghc(9,10,0) mkLocated HsFieldBind { hfbLHS = +# if MIN_VERSION_ghc(9,12,0) mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f +# else + mkLocated $ withPlaceHolder $ noExt Ambiguous $ valueRdrName f +# endif , hfbRHS = mkLocated e' , hfbPun = False , hfbAnn = mzero diff --git a/src/GHC/SourceGen/Overloaded.hs b/src/GHC/SourceGen/Overloaded.hs index b351f72..c31780c 100644 --- a/src/GHC/SourceGen/Overloaded.hs +++ b/src/GHC/SourceGen/Overloaded.hs @@ -21,17 +21,16 @@ module GHC.SourceGen.Overloaded import GHC.Hs.Type ( HsType(..) , HsTyVarBndr(..) +#if MIN_VERSION_ghc(9,12,0) , HsBndrVar(HsBndrVar) , HsBndrKind(HsBndrNoKind) +#endif #if MIN_VERSION_ghc(9,8,0) , HsBndrVis (HsBndrRequired) + , mkHsOpTy #endif ) -import GHC.Hs (IE(..), IEWrappedName(..) -#if MIN_VERSION_ghc(9,6,0) - , noExtField -#endif - ) +import GHC.Hs (IE(..), IEWrappedName(..)) #if !MIN_VERSION_ghc(8,6,0) import PlaceHolder(PlaceHolder(..)) #endif @@ -164,8 +163,11 @@ infixl 2 @@ instance App HsExpr' where #if MIN_VERSION_ghc(9,10,0) - op x o y - = noExt OpApp +# if MIN_VERSION_ghc(9,12,0) + op x o y = noExt OpApp +# else + op x o y = OpApp [] +# endif (parenthesizeExprForOp $ mkLocated x) (mkLocated $ var o) (parenthesizeExprForOp $ mkLocated y) @@ -190,7 +192,7 @@ instance App HsExpr' where instance App HsType' where op x o y #if MIN_VERSION_ghc(9,10,0) - = noExt HsOpTy notPromoted (parenthesizeTypeForOp $ mkLocated x) + = mkHsOpTy notPromoted (parenthesizeTypeForOp $ mkLocated x) (typeRdrName o) (parenthesizeTypeForOp $ mkLocated y) #elif MIN_VERSION_ghc(9,4,0) @@ -341,13 +343,16 @@ instance Var HsType' where instance BVar HsType' where bvar = var . UnqualStr -#if MIN_VERSION_ghc(9,10,0) +#if MIN_VERSION_ghc(9,12,0) instance BVar HsTyVarBndr' where bvar n = HsTvb noAnn (noExt HsBndrRequired) (noExt HsBndrVar $ typeRdrName $ UnqualStr n) (noExt HsBndrNoKind) - --bvar = UserTyVar noAnn (noExt HsBndrRequired) . typeRdrName . UnqualStr instance BVar HsTyVarBndrS' where bvar n = HsTvb noAnn SpecifiedSpec (noExt HsBndrVar $ typeRdrName $ UnqualStr n) (noExt HsBndrNoKind) - --bvar = UserTyVar noAnn SpecifiedSpec . typeRdrName . UnqualStr +#elif MIN_VERSION_ghc(9,10,0) +instance BVar HsTyVarBndr' where + bvar = UserTyVar noAnn (noExt HsBndrRequired) . typeRdrName . UnqualStr +instance BVar HsTyVarBndrS' where + bvar = UserTyVar noAnn SpecifiedSpec . typeRdrName . UnqualStr #elif MIN_VERSION_ghc(9,8,0) instance BVar HsTyVarBndr' where bvar = withEpAnnNotUsed UserTyVar HsBndrRequired . typeRdrName . UnqualStr diff --git a/src/GHC/SourceGen/Pat.hs b/src/GHC/SourceGen/Pat.hs index 4021f11..f432080 100644 --- a/src/GHC/SourceGen/Pat.hs +++ b/src/GHC/SourceGen/Pat.hs @@ -97,7 +97,11 @@ recordConP c fs = ConPatIn #endif (valueRdrName c) +#if MIN_VERSION_ghc(9,12,0) $ RecCon $ noExt HsRecFields (map mkRecField fs) Nothing -- No ".." +#else + $ RecCon $ HsRecFields (map mkRecField fs) Nothing -- No ".." +#endif where mkRecField :: (RdrNameStr, Pat') -> LHsRecField' LPat' mkRecField (f, p) = diff --git a/src/GHC/SourceGen/Type.hs b/src/GHC/SourceGen/Type.hs index 901f2a2..6a23a65 100644 --- a/src/GHC/SourceGen/Type.hs +++ b/src/GHC/SourceGen/Type.hs @@ -29,10 +29,12 @@ import GHC.Parser.Annotation import GHC.Hs.Type #endif -import Language.Haskell.Syntax.Type #if MIN_VERSION_ghc(9,4,0) import Language.Haskell.Syntax.Extension #endif +#if MIN_VERSION_ghc(9,12,0) +import Language.Haskell.Syntax.Type +#endif import GHC.SourceGen.Syntax.Internal import GHC.SourceGen.Lit.Internal (noSourceText) @@ -70,8 +72,10 @@ listPromotedTy = withPlaceHolder (withEpAnnNotUsed HsExplicitListTy promoted) . #endif tuplePromotedTy :: [HsType'] -> HsType' -#if MIN_VERSION_ghc(9,10,0) +#if MIN_VERSION_ghc(9,12,0) tuplePromotedTy = withPlaceHolders (HsExplicitTupleTy noAnn IsPromoted) . map mkLocated +#elif MIN_VERSION_ghc(9,10,0) +tuplePromotedTy = withPlaceHolders (withEpAnnNotUsed (HsExplicitTupleTy [])) . map mkLocated #else tuplePromotedTy = withPlaceHolders (withEpAnnNotUsed HsExplicitTupleTy) . map mkLocated #endif @@ -158,12 +162,13 @@ infixr 0 ==> -- > kindedVar "x" (var "A") kindedVar :: OccNameStr -> HsType' -> HsTyVarBndr' kindedVar v t = -#if MIN_VERSION_ghc(9,10,0) +#if MIN_VERSION_ghc(9,12,0) HsTvb noAnn (noExt HsBndrRequired) (noExt HsBndrVar $ typeRdrName $ UnqualStr v) (noExt HsBndrKind $ mkLocated t) - -- KindedTyVar - -- [] - -- (noExt HsBndrRequired) - -- (typeRdrName $ UnqualStr v) (mkLocated t) +#elif MIN_VERSION_ghc(9,10,0) + KindedTyVar + [] + (noExt HsBndrRequired) + (typeRdrName $ UnqualStr v) (mkLocated t) #elif MIN_VERSION_ghc(9,8,0) withEpAnnNotUsed KindedTyVar HsBndrRequired From 7beb8affc424896fc98a9cf4f0a56dd665cfc487 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 16:56:45 +0200 Subject: [PATCH 06/12] Build for GHC 9.12 on CI --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 88761d1..897b928 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - ghc: ["9.0", "9.2", "9.4", "9.6", "9.8", "9.10"] + ghc: ["9.0", "9.2", "9.4", "9.6", "9.8", "9.10", "9.12"] env: STACK_YAML: stack-${{ matrix.ghc }}.yaml runs-on: ${{ matrix.os }} From 1c4013731d272d8a3cccc4151b684fcf1b8a6f47 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 17:01:09 +0200 Subject: [PATCH 07/12] Clean up --- src/GHC/SourceGen/Binds.hs | 1 - src/GHC/SourceGen/Decl.hs | 8 -------- src/GHC/SourceGen/Expr.hs | 2 -- 3 files changed, 11 deletions(-) diff --git a/src/GHC/SourceGen/Binds.hs b/src/GHC/SourceGen/Binds.hs index 729cea3..ebf3f2b 100644 --- a/src/GHC/SourceGen/Binds.hs +++ b/src/GHC/SourceGen/Binds.hs @@ -211,7 +211,6 @@ patBindGRHSs p g = $ withPlaceHolder (withPlaceHolder (noExt PatBind (builtPat p) (noExt HsNoMultAnn) (mkGRHSs g))) --- GHC913 (noExt PatBind (builtPat p) (HsUnannotated EpPatBind) (mkGRHSs g))) #elif MIN_VERSION_ghc(9,6,0) bindB $ withPlaceHolder diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 9806717..81db2e0 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -483,12 +483,10 @@ data' = newOrDataType DataType -- > prefixCon "Foo" [field (var "a"), field (var "Int")] prefixCon :: OccNameStr -> [Field] -> ConDecl' prefixCon name fields = renderCon98Decl name --- GHC913 $ prefixCon' $ map renderField fields $ prefixCon' $ map (hsUnrestricted . renderField) fields where #if MIN_VERSION_ghc(9,2,0) prefixCon' = PrefixCon [] --- GHC913 prefixCon' = PrefixCon #else prefixCon' = PrefixCon #endif @@ -502,7 +500,6 @@ prefixCon name fields = renderCon98Decl name infixCon :: Field -> OccNameStr -> Field -> ConDecl' infixCon f name f' = renderCon98Decl name $ InfixCon (hsUnrestricted $ renderField f) (hsUnrestricted $ renderField f') --- GHC913 $ InfixCon (renderField f) (renderField f') -- | Declares Haskell-98-style record constructor for a data or type -- declaration. @@ -516,7 +513,6 @@ recordCon name fields = renderCon98Decl name where mkLConDeclField (n, f) = #if MIN_VERSION_ghc(9,10,0) --- GHC913 mkLocated $ noExt HsConDeclRecField mkLocated $ ConDeclField noAnn [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n] #elif MIN_VERSION_ghc(9,4,0) @@ -528,7 +524,6 @@ recordCon name fields = renderCon98Decl name #endif (renderField f) Nothing --- GHC913 --Nothing -- | An individual argument of a data constructor. Contains a type for the field, -- and whether the field is strict or lazy. @@ -569,11 +564,9 @@ hsUnrestricted :: a -> a hsUnrestricted = id #endif ---GHC913 renderField :: Field -> HsConDeclField GhcPs renderField :: Field -> LHsType GhcPs -- TODO: parenthesizeTypeForApp is an overestimate in the case of -- rendering an infix or record type. ---GHC913 renderField f = hsPlainTypeField $ wrap $ parenthesizeTypeForApp $ mkLocated $ fieldType f renderField f = wrap $ parenthesizeTypeForApp $ mkLocated $ fieldType f where wrap = case strictness f of @@ -758,7 +751,6 @@ patSynBind :: OccNameStr -> [OccNameStr] -> Pat' -> HsDecl' patSynBind n ns p = bindB $ noExt PatSynBind $ withPlaceHolder (PSB noAnn (valueRdrName $ unqual n)) (PrefixCon [] (map (valueRdrName . unqual) ns)) --- GHC913 (PrefixCon (map (valueRdrName . unqual) ns)) (builtPat p) ImplicitBidirectional #else diff --git a/src/GHC/SourceGen/Expr.hs b/src/GHC/SourceGen/Expr.hs index 126acf4..493b65d 100644 --- a/src/GHC/SourceGen/Expr.hs +++ b/src/GHC/SourceGen/Expr.hs @@ -62,7 +62,6 @@ import SrcLoc (unLoc, GenLocated(..)) import GHC.Parser.Annotation (EpAnn(..)) #endif --- GHC913 import qualified Data.List.NonEmpty as NonEmpty import GHC.SourceGen.Binds.Internal import GHC.SourceGen.Binds import GHC.SourceGen.Expr.Internal @@ -168,7 +167,6 @@ multiIf :: [GuardedExpr] -> HsExpr' multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . map mkLocated #elif MIN_VERSION_ghc(9,10,0) multiIf = withPlaceHolder (HsMultiIf []) . map mkLocated --- GHC913 multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . NonEmpty.fromList . map mkLocated #elif MIN_VERSION_ghc(9,4,0) multiIf = withPlaceHolder (withEpAnnNotUsed HsMultiIf) . map mkLocated #else From ac8153cd2bdea19d859b5ea3b7abbf592e97e4fa Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 26 Aug 2025 17:06:44 +0200 Subject: [PATCH 08/12] Do not permit newer versions --- stack-9.10.yaml | 2 -- stack-9.12.yaml | 2 -- 2 files changed, 4 deletions(-) diff --git a/stack-9.10.yaml b/stack-9.10.yaml index 65962c6..babf42e 100644 --- a/stack-9.10.yaml +++ b/stack-9.10.yaml @@ -13,5 +13,3 @@ packages: ghc-options: "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports - -allow-newer: true diff --git a/stack-9.12.yaml b/stack-9.12.yaml index 0ec7802..a3a9ba5 100644 --- a/stack-9.12.yaml +++ b/stack-9.12.yaml @@ -13,5 +13,3 @@ packages: ghc-options: "$locals": -Wall -Werror -Wwarn=unused-imports -Wwarn=dodgy-imports - -allow-newer: true From 5d454f1656854a9ce5fb5e6776b7a53b5c2597c6 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 29 Aug 2025 09:37:04 +0200 Subject: [PATCH 09/12] Refactor --- src/GHC/SourceGen/Module.hs | 47 ++++--------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/src/GHC/SourceGen/Module.hs b/src/GHC/SourceGen/Module.hs index 62724c4..4a062ab 100644 --- a/src/GHC/SourceGen/Module.hs +++ b/src/GHC/SourceGen/Module.hs @@ -29,14 +29,13 @@ module GHC.SourceGen.Module import GHC.Hs.ImpExp ( IEWildcard(..), IEWrappedName(..), IE(..) #if MIN_VERSION_ghc(9,6,0) - , ImportListInterpretation (EverythingBut, Exactly), XImportDeclPass (ideclSourceText, ideclImplicit) -#else - , LIEWrappedName + , ImportListInterpretation (EverythingBut, Exactly) #endif ) import GHC.Hs ( HsModule(..) , ImportDecl(..) + , simpleImportDecl #if MIN_VERSION_ghc(8,10,0) , ImportDeclQualifiedStyle(..) #endif @@ -48,6 +47,8 @@ import GHC.Hs #endif #if MIN_VERSION_ghc(9,6,0) , hsmodDeprecMessage, hsmodHaddockModHeader, hsmodAnn, XModulePs (XModulePs, hsmodLayout), noAnn, GhcPs, XImportDeclPass (XImportDeclPass, ideclAnn), SrcSpanAnnA, noExtField +#else + , LIEWrappedName #endif ) #if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) @@ -69,7 +70,6 @@ import GHC.Parser.Annotation (EpLayout (..), noAnn) import GHC.SourceGen.Syntax.Internal import GHC.SourceGen.Name.Internal -import GHC.SourceGen.Lit.Internal (noSourceText) import GHC.SourceGen.Name (unqual) #if MIN_VERSION_ghc(9,4,0) import GHC.SourceGen.Name (RdrNameStr, ModuleNameStr(unModuleNameStr), OccNameStr) @@ -123,44 +123,7 @@ as' :: ImportDecl' -> ModuleNameStr -> ImportDecl' as' d m = d { ideclAs = Just (mkLocated $ unModuleNameStr m) } import' :: ModuleNameStr -> ImportDecl' -import' m = importDecl - (mkLocated $ unModuleNameStr m) -#if MIN_VERSION_ghc(9,4,0) - NoRawPkgQual -#else - Nothing -#endif -#if MIN_VERSION_ghc(9,0,0) - NotBoot -#else - False -#endif - False -#if MIN_VERSION_ghc(8,10,0) - NotQualified -#else - False -#endif -#if !MIN_VERSION_ghc(9,6,0) - False -#endif - Nothing Nothing - where -#if MIN_VERSION_ghc(9,10,0) - importDecl = ImportDecl - (XImportDeclPass{ ideclAnn = noAnn - , ideclSourceText = NoSourceText - , ideclImplicit = False - }) -#elif MIN_VERSION_ghc(9,6,0) - importDecl = ImportDecl - (XImportDeclPass{ ideclAnn = EpAnnNotUsed - , ideclSourceText = NoSourceText - , ideclImplicit = False - }) -#else - importDecl = noSourceText (withEpAnnNotUsed ImportDecl) -#endif +import' m = simpleImportDecl (unModuleNameStr m) exposing :: ImportDecl' -> [IE'] -> ImportDecl' exposing d ies = d From 7d32fa92077327ef728e06222a376eeaad6aa0c2 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 29 Aug 2025 09:48:04 +0200 Subject: [PATCH 10/12] Fix for 9.0 --- src/GHC/SourceGen/Binds/Internal.hs | 4 +++- src/GHC/SourceGen/Decl.hs | 1 - src/GHC/SourceGen/Lit.hs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index a8ef9f3..fec7042 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -29,7 +29,9 @@ import GHC.Hs.Expr (MatchGroup(..), Match(..), GRHSs(..)) import qualified Data.List.NonEmpty as NonEmpty -import Language.Haskell.Syntax.Extension (XRec, wrapXRec, noExtField) +#if MIN_VERSION_ghc(9,12,0) +import Language.Haskell.Syntax.Extension (wrapXRec, noExtField) +#endif import GHC.Types.SrcLoc (unLoc) #if !MIN_VERSION_ghc(8,6,0) diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 81db2e0..9d6819d 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -756,7 +756,6 @@ patSynBind n ns p = bindB $ noExt PatSynBind #else patSynBind n ns p = bindB $ noExt PatSynBind $ withPlaceHolder (withEpAnnNotUsed PSB (valueRdrName $ unqual n)) - (prefixCon' (map (valueRdrName . unqual) ns)) (prefixCon' (map (valueRdrName . unqual) ns)) (builtPat p) ImplicitBidirectional diff --git a/src/GHC/SourceGen/Lit.hs b/src/GHC/SourceGen/Lit.hs index 8cd2a4c..6ddb617 100644 --- a/src/GHC/SourceGen/Lit.hs +++ b/src/GHC/SourceGen/Lit.hs @@ -20,6 +20,7 @@ module GHC.SourceGen.Lit #if MIN_VERSION_ghc(9,2,0) import GHC.Types.SourceText (mkTHFractionalLit, mkIntegralLit) import GHC.Data.FastString (fsLit) +import GHC.Parser.Annotation (noAnn) #elif MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic (mkFractionalLit, mkIntegralLit) import GHC.Data.FastString (fsLit) @@ -31,7 +32,6 @@ import GHC.Hs.Lit import GHC.Hs.Expr (noExpr, noSyntaxExpr, HsExpr(..)) import GHC.Hs.Pat (Pat(..)) -import GHC.Parser.Annotation (EpLayout (..), noAnn) import GHC.SourceGen.Lit.Internal import GHC.SourceGen.Syntax.Internal From 089ca964964fcdb182f2071d4d590b5ecdfd306b Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 29 Aug 2025 11:19:40 +0200 Subject: [PATCH 11/12] Fix regression for < 9.0 --- src/GHC/SourceGen/Type.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/GHC/SourceGen/Type.hs b/src/GHC/SourceGen/Type.hs index 6a23a65..fd66b5b 100644 --- a/src/GHC/SourceGen/Type.hs +++ b/src/GHC/SourceGen/Type.hs @@ -91,16 +91,16 @@ a --> b = (noExt HsFunTy) --(HsUnannotated (EpArrow (EpUniTok noSpanAnchor NormalSyntax))) (HsUnrestrictedArrow (EpUniTok noSpanAnchor NormalSyntax)) - (parenthesizeTypeForFun $ mkLocated a) (mkLocated b) #elif MIN_VERSION_ghc(9,4,0) withEpAnnNotUsed HsFunTy (HsUnrestrictedArrow mkUniToken) - (parenthesizeTypeForFun $ mkLocated a) (mkLocated b) #elif MIN_VERSION_ghc(9,0,0) withEpAnnNotUsed HsFunTy (HsUnrestrictedArrow NormalSyntax) - (parenthesizeTypeForFun $ mkLocated a) (mkLocated b) +#else + withEpAnnNotUsed HsFunTy #endif + (parenthesizeTypeForFun $ mkLocated a) (mkLocated b) infixr 0 --> @@ -177,4 +177,7 @@ kindedVar v t = withEpAnnNotUsed KindedTyVar () (typeRdrName $ UnqualStr v) (mkLocated t) +#else + withEpAnnNotUsed KindedTyVar + (typeRdrName $ UnqualStr v) (mkLocated t) #endif From a81dd2e71c3957f65c94a6dea7d77697ac2e3d36 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 29 Aug 2025 11:38:41 +0200 Subject: [PATCH 12/12] More fixes for GHC < 9.0 --- src/GHC/SourceGen/Binds/Internal.hs | 7 +------ src/GHC/SourceGen/Decl.hs | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index fec7042..5a9b1c8 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -27,13 +27,10 @@ import GHC.Hs.Binds import GHC.Hs.Decls import GHC.Hs.Expr (MatchGroup(..), Match(..), GRHSs(..)) -import qualified Data.List.NonEmpty as NonEmpty - #if MIN_VERSION_ghc(9,12,0) import Language.Haskell.Syntax.Extension (wrapXRec, noExtField) #endif -import GHC.Types.SrcLoc (unLoc) #if !MIN_VERSION_ghc(8,6,0) import PlaceHolder (PlaceHolder(..)) #endif @@ -150,9 +147,7 @@ matchGroup context matches = mkGRHSs :: RawGRHSs -> GRHSs' LHsExpr' mkGRHSs g = withEmptyEpAnnComments GRHSs --mkGRHSs g = GRHSs emptyComments -#if MIN_VERSION_ghc(9,14,0) - (NonEmpty.fromList $ map mkLocated $ rawGRHSs g) -#elif MIN_VERSION_ghc(9,4,0) +#if MIN_VERSION_ghc(9,4,0) (map mkLocated $ rawGRHSs g) #else (map builtLoc $ rawGRHSs g) diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 9d6819d..972b7e7 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -54,9 +54,11 @@ module GHC.SourceGen.Decl #if MIN_VERSION_ghc(9,0,0) import GHC (LexicalFixity(Prefix)) import GHC.Data.Bag (listToBag) +import GHC.Hs #if MIN_VERSION_ghc(9,10,0) import GHC (GhcPs) +import GHC.Parser.PostProcess (mkBangTy) #elif MIN_VERSION_ghc(9,6,0) import GHC (GhcPs, LayoutInfo (NoLayoutInfo)) #else @@ -66,13 +68,13 @@ import GHC.Types.SrcLoc (LayoutInfo(NoLayoutInfo)) #else import BasicTypes (LexicalFixity(Prefix)) import Bag (listToBag) +import GHC.Hs.Extension (GhcPs) #endif #if !MIN_VERSION_ghc(8,6,0) import BasicTypes (DerivStrategy(..)) #endif import GHC.Hs.Binds import GHC.Hs.Decls -import GHC.Parser.PostProcess (mkBangTy) import GHC.Hs.Type ( @@ -89,14 +91,13 @@ import GHC.Hs.Type , LHsType #if MIN_VERSION_ghc(8,6,0) , HsWildCardBndrs (..) + , ConDeclField (..) #endif #if MIN_VERSION_ghc(8,8,0) , HsArg(..) #endif , SrcStrictness(..) , SrcUnpackedness(..) -#if MIN_VERSION_ghc(9,0,0) -#endif ) #if MIN_VERSION_ghc(9,10,0) @@ -117,7 +118,6 @@ 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. --