ghc-source-gen 0.4.6.0 → 0.4.7.0
raw patch · 13 files changed
+235/−146 lines, 13 filesdep ~QuickCheckdep ~ghcdep ~tasty-quickcheckPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: QuickCheck, ghc, tasty-quickcheck
API changes (from Hackage documentation)
- GHC.SourceGen.Type: type HsTyVarBndr' = HsTyVarBndr () GhcPs
+ GHC.SourceGen.Type: type HsTyVarBndr' = HsTyVarBndr HsBndrVis GhcPs GhcPs
Files
- ChangeLog.md +4/−0
- ghc-source-gen.cabal +8/−8
- src/GHC/SourceGen/Binds.hs +12/−8
- src/GHC/SourceGen/Binds/Internal.hs +25/−6
- src/GHC/SourceGen/Decl.hs +70/−28
- src/GHC/SourceGen/Expr.hs +41/−13
- src/GHC/SourceGen/Lit.hs +2/−1
- src/GHC/SourceGen/Module.hs +9/−46
- src/GHC/SourceGen/Overloaded.hs +26/−17
- src/GHC/SourceGen/Pat.hs +11/−7
- src/GHC/SourceGen/Pat/Internal.hs +3/−1
- src/GHC/SourceGen/Type.hs +22/−9
- src/GHC/SourceGen/Type/Internal.hs +2/−2
ChangeLog.md view
@@ -1,6 +1,10 @@ # Changelog for haskell-syntax +# 0.4.7.0+- Support GHC 9.12.+- Support GHC 9.14.+ # 0.4.6.0 - Support GHC 9.10.
ghc-source-gen.cabal view
@@ -1,11 +1,11 @@ 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.1. -- -- see: https://github.com/sol/hpack name: ghc-source-gen-version: 0.4.6.0+version: 0.4.7.0 synopsis: Constructs Haskell syntax trees for the GHC API. description: @ghc-source-gen@ is a library for generating Haskell source code. It uses the <https://hackage.haskell.org/package/ghc ghc> library@@ -61,7 +61,7 @@ TypeSynonymInstances build-depends: base >=4.7 && <5- , ghc >=8.4 && <9.11+ , ghc >=8.4 && <9.15 default-language: Haskell2010 if impl(ghc<8.10) other-modules:@@ -102,13 +102,13 @@ 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.15 , 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 @@ TypeSynonymInstances build-depends: base >=4.7 && <5- , ghc >=8.4 && <9.11+ , ghc >=8.4 && <9.15 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.6@@ -151,7 +151,7 @@ TypeSynonymInstances build-depends: base >=4.7 && <5- , ghc >=8.4 && <9.11+ , ghc >=8.4 && <9.15 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.6
src/GHC/SourceGen/Binds.hs view
@@ -81,7 +81,11 @@ 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 @@ 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. --@@ -198,20 +206,16 @@ -- > ] patBindGRHSs :: HasPatBind t => Pat' -> RawGRHSs -> t patBindGRHSs p g =-#if MIN_VERSION_ghc(9,10,0) bindB $ withPlaceHolder (withPlaceHolder+#if MIN_VERSION_ghc(9,14,0)+ (noExt PatBind (builtPat p) (HsUnannotated EpPatBind) (mkGRHSs g)))+#elif MIN_VERSION_ghc(9,10,0) (noExt PatBind (builtPat p) (noExt HsNoMultAnn) (mkGRHSs g))) #elif MIN_VERSION_ghc(9,6,0)- bindB- $ withPlaceHolder- (withPlaceHolder (withEpAnnNotUsed PatBind (builtPat p) (mkGRHSs g))) #else- bindB- $ withPlaceHolder- (withPlaceHolder (withEpAnnNotUsed PatBind (builtPat p) (mkGRHSs g))) $ ([],[]) #endif@@ -328,7 +332,7 @@ -- > 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
src/GHC/SourceGen/Binds/Internal.hs view
@@ -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 @@ #endif ) import GHC.Data.Bag (listToBag)+import GHC.Hs.Extension (GhcPs) #else import BasicTypes (Origin(Generated)) import Bag (listToBag)@@ -25,12 +27,19 @@ import GHC.Hs.Decls import GHC.Hs.Expr (MatchGroup(..), Match(..), GRHSs(..)) +#if MIN_VERSION_ghc(9,14,0)+import qualified Data.List.NonEmpty as NonEmpty+#endif+#if MIN_VERSION_ghc(9,12,0)+import Language.Haskell.Syntax.Extension (wrapXRec, noExtField)+#endif+ #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 +61,11 @@ #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@@ -121,18 +134,25 @@ matches' = mkLocated $ map (mkLocated . mkMatch) matches mkMatch :: RawMatch -> Match' LHsExpr' #if MIN_VERSION_ghc(9,10,0)- mkMatch r = Match [] context+# if MIN_VERSION_ghc(9,12,0)+ mkMatch r = Match noExtField context+ (wrapXRec @GhcPs $ map builtPat $ map parenthesize $ rawMatchPats r)+# else+ mkMatch r = Match noAnn context (map builtPat $ map parenthesize $ rawMatchPats r)- (mkGRHSs $ rawMatchGRHSs 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-#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 +186,6 @@ class HasValBind t where sigB :: Sig' -> t bindB :: HsBind' -> t- instance HasValBind HsDecl' where sigB = noExt SigD bindB = noExt ValD
src/GHC/SourceGen/Decl.hs view
@@ -54,9 +54,11 @@ #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,6 +68,7 @@ #else import BasicTypes (LexicalFixity(Prefix)) import Bag (listToBag)+import GHC.Hs.Extension (GhcPs) #endif #if !MIN_VERSION_ghc(8,6,0) import BasicTypes (DerivStrategy(..))@@ -74,8 +77,8 @@ import GHC.Hs.Decls import GHC.Hs.Type- ( ConDeclField(..)- , FieldOcc(..)+ (+ FieldOcc(..) , HsConDetails(..) #if !MIN_VERSION_ghc(9,2,0) , HsImplicitBndrs (..)@@ -94,9 +97,6 @@ #endif , SrcStrictness(..) , SrcUnpackedness(..)-#if MIN_VERSION_ghc(9,0,0)- , hsUnrestricted-#endif ) #if MIN_VERSION_ghc(9,10,0)@@ -117,7 +117,6 @@ 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. --@@ -185,7 +184,7 @@ = 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 +207,18 @@ ] , 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 } 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 +261,7 @@ 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 +269,11 @@ #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 = []@@ -295,14 +302,14 @@ 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 +360,7 @@ 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)@@ -374,7 +381,17 @@ 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+ $ HsDataDefn noAnn+ Nothing+ Nothing+ Nothing+ (mkDataDefnCon newOrData conDecls)+ (map mkLocated derivs)+#elif MIN_VERSION_ghc(9,10,0) DataDecl [] (typeRdrName $ unqual name) (mkQTyVars vars) Prefix@@ -465,9 +482,13 @@ -- > prefixCon "Foo" [field (var "a"), field (var "Int")] prefixCon :: OccNameStr -> [Field] -> ConDecl' prefixCon name fields = renderCon98Decl name+#if MIN_VERSION_ghc(9,14,0)+ $ prefixCon' $ map renderField fields+#else $ prefixCon' $ map (hsUnrestricted . renderField) fields+#endif where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,2,0) && !MIN_VERSION_ghc(9,14,0) prefixCon' = PrefixCon [] #else prefixCon' = PrefixCon@@ -481,7 +502,11 @@ -- > infixCon (field (var "A" @@ var "b")) ":+:" (field (Var "C" @@ var "d")) infixCon :: Field -> OccNameStr -> Field -> ConDecl' infixCon f name f' = renderCon98Decl name+#if MIN_VERSION_ghc(9,14,0)+ $ InfixCon (renderField f) (renderField f')+#else $ InfixCon (hsUnrestricted $ renderField f) (hsUnrestricted $ renderField f')+#endif -- | Declares Haskell-98-style record constructor for a data or type -- declaration.@@ -494,9 +519,12 @@ $ RecCon $ mkLocated $ map mkLConDeclField fields where mkLConDeclField (n, f) =-#if MIN_VERSION_ghc(9,10,0)- mkLocated $ ConDeclField []+#if MIN_VERSION_ghc(9,14,0)+ mkLocated $ noExt HsConDeclRecField [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n]+#elif MIN_VERSION_ghc(9,10,0)+ mkLocated $ ConDeclField noAnn+ [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n] #elif MIN_VERSION_ghc(9,4,0) mkLocated $ withEpAnnNotUsed ConDeclField [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n]@@ -505,7 +533,9 @@ [builtLoc $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n] #endif (renderField f)+#if !MIN_VERSION_ghc(9,14,0) Nothing+#endif -- | An individual argument of a data constructor. Contains a type for the field, -- and whether the field is strict or lazy.@@ -546,15 +576,23 @@ hsUnrestricted = id #endif +#if MIN_VERSION_ghc(9,14,0)+renderField :: Field -> HsConDeclField GhcPs+#else renderField :: Field -> LHsType GhcPs+#endif -- TODO: parenthesizeTypeForApp is an overestimate in the case of -- rendering an infix or record type.+#if MIN_VERSION_ghc(9,14,0)+renderField f = hsPlainTypeField $ wrap $ parenthesizeTypeForApp $ mkLocated $ fieldType f+#else renderField f = wrap $ parenthesizeTypeForApp $ mkLocated $ fieldType f+#endif 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 +602,7 @@ 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 +617,7 @@ 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 +635,7 @@ 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 +646,7 @@ 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 +657,7 @@ 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 +675,7 @@ 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 +690,7 @@ 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 +701,7 @@ 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 +712,7 @@ 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 +723,7 @@ 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,8 +769,12 @@ 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))+# if MIN_VERSION_ghc(9,14,0)+ (PrefixCon (map (valueRdrName . unqual) ns))+# else (PrefixCon [] (map (valueRdrName . unqual) ns))+# endif (builtPat p) ImplicitBidirectional #else
src/GHC/SourceGen/Expr.hs view
@@ -31,6 +31,7 @@ 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 @@ #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)@@ -66,6 +72,9 @@ , sigWcType , wcType )+#if MIN_VERSION_ghc(9,14,0)+import qualified Data.List.NonEmpty as NonEmpty+#endif -- | An overloaded label, as used with the @OverloadedLabels@ extension. --@@ -75,7 +84,9 @@ 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@@ -105,7 +116,11 @@ case' e matches = HsCase ann (mkLocated e) $ matchGroup CaseAlt matches where- ann = EpAnnHsCase noSpanAnchor noSpanAnchor []+# 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@@ -113,14 +128,14 @@ 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@@ -151,7 +166,11 @@ -- > , guardedStmt (var "otherwise") $ rhs (string "h") -- > ] multiIf :: [GuardedExpr] -> HsExpr'-#if MIN_VERSION_ghc(9,10,0)+#if MIN_VERSION_ghc(9,14,0)+multiIf = withPlaceHolder (HsMultiIf (NoEpTok, NoEpTok, NoEpTok)) . NonEmpty.fromList . map mkLocated+#elif 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 #elif MIN_VERSION_ghc(9,4,0) multiIf = withPlaceHolder (withEpAnnNotUsed HsMultiIf) . map mkLocated@@ -223,7 +242,7 @@ -- > 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 +282,19 @@ -- > 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)+#if MIN_VERSION_ghc(9,12,0)+ $ noExt HsRecFields+#else+ $ HsRecFields+#endif+ (map recField fs) Nothing -- No ".." where recField :: (RdrNameStr, HsExpr') -> LHsRecField' LHsExpr'@@ -281,7 +305,7 @@ 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 +342,7 @@ 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 +355,14 @@ #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 = []+ , hfbAnn = mzero #elif MIN_VERSION_ghc(9,4,0) mkLocated HsFieldBind { hfbLHS =@@ -366,7 +394,7 @@ 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
src/GHC/SourceGen/Lit.hs view
@@ -20,6 +20,7 @@ #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)@@ -51,7 +52,7 @@ 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
src/GHC/SourceGen/Module.hs view
@@ -29,14 +29,13 @@ 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@@ -47,7 +46,9 @@ , 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+#else+ , LIEWrappedName #endif ) #if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0)@@ -69,7 +70,6 @@ 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' 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@@ -195,7 +158,7 @@ -- > 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 +170,7 @@ -- > 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 +200,7 @@ -- > 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
src/GHC/SourceGen/Overloaded.hs view
@@ -21,15 +21,16 @@ 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)-#endif- )-import GHC.Hs (IE(..), IEWrappedName(..)-#if MIN_VERSION_ghc(9,6,0)- , noExtField+ , mkHsOpTy #endif )+import GHC.Hs (IE(..), IEWrappedName(..)) #if !MIN_VERSION_ghc(8,6,0) import PlaceHolder(PlaceHolder(..)) #endif@@ -45,7 +46,7 @@ #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 +95,7 @@ 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@@ -162,8 +163,11 @@ instance App HsExpr' where #if MIN_VERSION_ghc(9,10,0)- op x o y- = 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)@@ -188,7 +192,7 @@ instance App HsType' where op x o y #if MIN_VERSION_ghc(9,10,0)- = HsOpTy [] notPromoted (parenthesizeTypeForOp $ mkLocated x)+ = mkHsOpTy notPromoted (parenthesizeTypeForOp $ mkLocated x) (typeRdrName o) (parenthesizeTypeForOp $ mkLocated y) #elif MIN_VERSION_ghc(9,4,0)@@ -216,7 +220,7 @@ #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 +240,7 @@ 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 +255,7 @@ 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 +335,7 @@ 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@@ -339,11 +343,16 @@ 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 = UserTyVar [] (noExt HsBndrRequired) . typeRdrName . UnqualStr+ bvar n = HsTvb noAnn (noExt HsBndrRequired) (noExt HsBndrVar $ typeRdrName $ UnqualStr n) (noExt HsBndrNoKind) instance BVar HsTyVarBndrS' where- bvar = UserTyVar [] SpecifiedSpec . typeRdrName . UnqualStr+ bvar n = HsTvb noAnn SpecifiedSpec (noExt HsBndrVar $ typeRdrName $ UnqualStr n) (noExt HsBndrNoKind)+#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
src/GHC/SourceGen/Pat.hs view
@@ -64,16 +64,16 @@ -- > ===== -- > 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,14,0) && MIN_VERSION_ghc(9,2,0) prefixCon = PrefixCon [] #else prefixCon = PrefixCon@@ -90,14 +90,18 @@ 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)+#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) =@@ -132,7 +136,7 @@ -- > 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 +148,7 @@ -- > 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 +160,7 @@ -- > 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)
src/GHC/SourceGen/Pat/Internal.hs view
@@ -32,7 +32,9 @@ 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
src/GHC/SourceGen/Type.hs view
@@ -32,6 +32,9 @@ #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)@@ -41,7 +44,7 @@ -- | 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 +57,7 @@ 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,13 +66,15 @@ -- 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)+#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@@ -82,19 +87,22 @@ -- > var "a" --> var "b" (-->) :: HsType' -> HsType' -> HsType' a --> b =-#if MIN_VERSION_ghc(9,10,0)+#if MIN_VERSION_ghc(9,14,0) (noExt HsFunTy)+ (HsUnannotated (EpArrow (EpUniTok noSpanAnchor NormalSyntax)))+#elif MIN_VERSION_ghc(9,10,0)+ (noExt HsFunTy) (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 --> @@ -156,7 +164,9 @@ -- > 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)+#elif MIN_VERSION_ghc(9,10,0) KindedTyVar [] (noExt HsBndrRequired)@@ -168,5 +178,8 @@ #elif MIN_VERSION_ghc(9,0,0) withEpAnnNotUsed KindedTyVar ()+ (typeRdrName $ UnqualStr v) (mkLocated t)+#else+ withEpAnnNotUsed KindedTyVar (typeRdrName $ UnqualStr v) (mkLocated t) #endif
src/GHC/SourceGen/Type/Internal.hs view
@@ -18,7 +18,7 @@ #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 @@ 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