packages feed

ghc-source-gen 0.4.5.0 → 0.4.6.0

raw patch · 15 files changed

+575/−133 lines, 15 filesdep ~basedep ~ghcPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, ghc

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,6 +1,9 @@ # Changelog for haskell-syntax  +# 0.4.6.0+- Support GHC 9.10.+ # 0.4.5.0 - Support GHC 9.8. 
ghc-source-gen.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           ghc-source-gen-version:        0.4.5.0+version:        0.4.6.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.9+    , ghc >=8.4 && <9.11   default-language: Haskell2010   if impl(ghc<8.10)     other-modules:@@ -104,7 +104,7 @@   build-depends:       QuickCheck >=2.10 && <2.15     , base >=4.7 && <5-    , ghc >=8.4 && <9.9+    , ghc >=8.4 && <9.11     , ghc-source-gen     , tasty >=1.0 && <1.6     , tasty-hunit ==0.10.*@@ -125,7 +125,7 @@       TypeSynonymInstances   build-depends:       base >=4.7 && <5-    , ghc >=8.4 && <9.9+    , ghc >=8.4 && <9.11     , 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.9+    , ghc >=8.4 && <9.11     , ghc-paths ==0.1.*     , ghc-source-gen     , tasty >=1.0 && <1.6
src/GHC/SourceGen/Binds.hs view
@@ -60,6 +60,10 @@ #if !MIN_VERSION_ghc(9,0,1) import GHC.Tc.Types.Evidence (HsWrapper(WpHole)) #endif++#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (noAnn)+#endif import GHC.SourceGen.Binds.Internal import GHC.SourceGen.Name import GHC.SourceGen.Name.Internal@@ -73,8 +77,15 @@ -- > typeSigs ["f", "g"] (var "A") typeSigs :: HasValBind t => [OccNameStr] -> HsType' -> t typeSigs names t =+#if MIN_VERSION_ghc(9,10,0)+    sigB $ TypeSig ann (map (typeRdrName . unqual) names)+        $ sigWcType t+  where+    ann = AnnSig noAnn []+#else     sigB $ withEpAnnNotUsed TypeSig (map (typeRdrName . unqual) names)         $ sigWcType t+#endif  -- | Declares the type of a single function or value. --@@ -187,11 +198,21 @@ -- >       ] patBindGRHSs :: HasPatBind t => Pat' -> RawGRHSs -> t patBindGRHSs p g =+#if MIN_VERSION_ghc(9,10,0)     bindB         $ withPlaceHolder             (withPlaceHolder+                (noExt PatBind (builtPat p) (noExt HsNoMultAnn) (mkGRHSs g)))+#elif MIN_VERSION_ghc(9,6,0)+    bindB+        $ withPlaceHolder+            (withPlaceHolder                 (withEpAnnNotUsed PatBind (builtPat p) (mkGRHSs g)))-#if !MIN_VERSION_ghc(9,6,0)+#else+    bindB+        $ withPlaceHolder+            (withPlaceHolder+                (withEpAnnNotUsed PatBind (builtPat p) (mkGRHSs g)))         $ ([],[]) #endif @@ -285,7 +306,11 @@ -- > ===== -- > guards [conP "Just" (bvar "x") <-- var "y", bvar "x"] unit guards :: [Stmt'] -> HsExpr' -> GuardedExpr+#if MIN_VERSION_ghc(9,10,0)+guards stmts e = GRHS noAnn (map mkLocated stmts) (mkLocated e)+#else guards stmts e = withEpAnnNotUsed GRHS (map mkLocated stmts) (mkLocated e)+#endif  -- | An expression statement.  May be used in a do expression (with 'do'') or in a -- match (with 'guard').@@ -302,8 +327,12 @@ -- > ===== -- > bvar "x" <-- var "act" (<--) :: Pat' -> HsExpr' -> Stmt'+#if MIN_VERSION_ghc(9,10,0)+p <-- e = withPlaceHolder $ BindStmt [] (builtPat p) (mkLocated e)+#elif MIN_VERSION_ghc(9,0,0) p <-- e = withPlaceHolder $ withEpAnnNotUsed BindStmt (builtPat p) (mkLocated e)-#if !MIN_VERSION_ghc(9,0,0)+#else+p <-- e = withPlaceHolder $ withEpAnnNotUsed BindStmt (builtPat p) (mkLocated e)          noSyntaxExpr noSyntaxExpr #endif infixl 1 <--
src/GHC/SourceGen/Binds/Internal.hs view
@@ -9,6 +9,9 @@  #if MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic ( Origin(Generated)+#if MIN_VERSION_ghc(9,10,0)+                       , GenReason(OtherExpansion)+#endif #if MIN_VERSION_ghc(9,8,0)                        , DoPmc (DoPmc) #endif@@ -26,6 +29,10 @@ import PlaceHolder (PlaceHolder(..)) #endif +#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (noAnn)+#endif+ import GHC.SourceGen.Pat.Internal (parenthesize) import GHC.SourceGen.Syntax.Internal @@ -42,14 +49,22 @@ -- This case prevents GHC from printing an empty "where" clause: valBinds [] = noExt EmptyLocalBinds valBinds vbs =+#if MIN_VERSION_ghc(9,10,0)+    HsValBinds noAnn+        $ withNoAnnSortKey ValBinds+            (listToBag $ map mkLocated binds)+            (map mkLocated sigs)+#elif MIN_VERSION_ghc(8,6,0)     withEpAnnNotUsed HsValBinds-#if MIN_VERSION_ghc(8,6,0)         $ withNoAnnSortKey ValBinds+            (listToBag $ map mkLocated binds)+            (map mkLocated sigs) #else+    withEpAnnNotUsed HsValBinds         $ noExt ValBindsIn-#endif             (listToBag $ map mkLocated binds)             (map mkLocated sigs)+#endif   where     sigs = [s | SigV s <- vbs]     binds = [b | BindV b <- vbs]@@ -87,7 +102,9 @@  matchGroup :: HsMatchContext' -> [RawMatch] -> MatchGroup' LHsExpr' matchGroup context matches =-#if MIN_VERSION_ghc(9,8,0)+#if MIN_VERSION_ghc(9,10,0)+    MG (Generated OtherExpansion DoPmc)+#elif MIN_VERSION_ghc(9,8,0)     MG (Generated DoPmc) #elif MIN_VERSION_ghc(9,6,0)     MG Generated@@ -99,13 +116,19 @@                             [] PlaceHolder #elif !MIN_VERSION_ghc(9,6,0)                             Generated-#endif                            +#endif   where     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)+                    (mkGRHSs $ rawMatchGRHSs r)+#else     mkMatch r = withEpAnnNotUsed Match context                     (map builtPat $ map parenthesize $ rawMatchPats r)                     (mkGRHSs $ rawMatchGRHSs r)+#endif  mkGRHSs :: RawGRHSs -> GRHSs' LHsExpr' mkGRHSs g = withEmptyEpAnnComments GRHSs@@ -135,7 +158,7 @@ -- To declare the type of a function or value, use -- 'GHC.SourceGen.Binds.typeSig' or 'GHC.SourceGen.Binds.typeSigs'. ----- To define a function, use +-- To define a function, use -- 'GHC.SourceGen.Binds.funBind' or 'GHC.SourceGen.Binds.funBinds'. -- -- To define a value, use
src/GHC/SourceGen/Decl.hs view
@@ -55,7 +55,9 @@ import GHC (LexicalFixity(Prefix)) import GHC.Data.Bag (listToBag) -#if MIN_VERSION_ghc(9,6,0)+#if MIN_VERSION_ghc(9,10,0)+import GHC (GhcPs)+#elif MIN_VERSION_ghc(9,6,0) import GHC (GhcPs, LayoutInfo (NoLayoutInfo)) #else import GHC.Types.SrcLoc (LayoutInfo(NoLayoutInfo))@@ -97,7 +99,9 @@ #endif     ) -#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (AnnSortKey(..), EpAnn(..), EpLayout (EpNoLayout))+#elif MIN_VERSION_ghc(9,2,0) import GHC.Parser.Annotation (AnnSortKey(..), EpAnn(..)) #elif MIN_VERSION_ghc(8,10,0) import GHC.Hs.Extension (NoExtField(NoExtField))@@ -180,7 +184,9 @@ class' context name vars decls     = noExt TyClD $ ClassDecl             { tcdCtxt = toHsContext $ mkLocated $ map mkLocated context-#if MIN_VERSION_ghc(9,6,0)+#if MIN_VERSION_ghc(9,10,0)+            , tcdCExt = ([], EpNoLayout, NoAnnSortKey)+#elif MIN_VERSION_ghc(9,6,0)             , tcdLayout = NoLayoutInfo             , tcdCExt = (EpAnnNotUsed, NoAnnSortKey) #elif MIN_VERSION_ghc(9,2,0)@@ -208,7 +214,9 @@             , tcdDocs = []  -- Haddocks             }   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    funDep' = FunDep []+#elif MIN_VERSION_ghc(9,2,0)     funDep' = withEpAnnNotUsed FunDep #else     funDep' = (,)@@ -249,7 +257,9 @@ instance' :: HsType' -> [RawInstDecl] -> HsDecl' instance' ty decls = noExt InstD  $ noExt ClsInstD $ ClsInstDecl     { cid_poly_ty = sigType ty-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    , cid_ext = (Nothing, [], NoAnnSortKey)+#elif MIN_VERSION_ghc(9,2,0)     , cid_ext = (EpAnnNotUsed, NoAnnSortKey) #elif MIN_VERSION_ghc(8,10,0)     , cid_ext = NoExtField@@ -281,8 +291,22 @@ -- > ===== -- > tyFamInst "Elt" [var "String"] (var "Char") tyFamInst :: HasTyFamInst t => RdrNameStr -> [HsType'] -> HsType' -> t+#if MIN_VERSION_ghc(9,10,0) tyFamInst name params ty = tyFamInstD         $ tyFamInstDecl+        $ FamEqn+            []+            (typeRdrName name)+            eqnBndrs+            (map (noExt HsValArg . mkLocated) params)+            Prefix+            (mkLocated ty)+  where+    tyFamInstDecl = TyFamInstDecl []+    eqnBndrs = noExt HsOuterImplicit+#elif MIN_VERSION_ghc(9,2,0)+tyFamInst name params ty = tyFamInstD+        $ tyFamInstDecl         $ famEqn             (typeRdrName name)             eqn_bndrs@@ -290,21 +314,34 @@             Prefix             (mkLocated ty)   where-#if MIN_VERSION_ghc(9,2,0)     tyFamInstDecl = withEpAnnNotUsed TyFamInstDecl-#else-    tyFamInstDecl = TyFamInstDecl . withPlaceHolder . noExt (withPlaceHolder HsIB)-#endif-#if MIN_VERSION_ghc(9,2,0)     famEqn tycon bndrs pats = withEpAnnNotUsed FamEqn tycon bndrs (map HsValArg pats)+    eqn_bndrs = noExt HsOuterImplicit #elif MIN_VERSION_ghc(8,8,0)-    famEqn tycon bndrs pats = noExt FamEqn tycon bndrs (map HsValArg pats)+tyFamInst name params ty = tyFamInstD+        $ tyFamInstDecl+        $ famEqn+            (typeRdrName name)+            eqn_bndrs+            (map mkLocated params)+            Prefix+            (mkLocated ty)+  where+    tyFamInstDecl = TyFamInstDecl . withPlaceHolder . noExt (withPlaceHolder HsIB)+    famEqn tycon bndrs pats = noExt FamEqn tycon bndrs (map HsValArg  pats)+    eqn_bndrs = Nothing #else+tyFamInst name params ty = tyFamInstD+        $ tyFamInstDecl+        $ famEqn+            (typeRdrName name)+            eqn_bndrs+            (map mkLocated params)+            Prefix+            (mkLocated ty)+  where+    tyFamInstDecl = TyFamInstDecl . withPlaceHolder . noExt (withPlaceHolder HsIB)     famEqn tycon _ = noExt FamEqn tycon-#endif-#if MIN_VERSION_ghc(9,2,0)-    eqn_bndrs = noExt HsOuterImplicit-#else     eqn_bndrs = Nothing #endif @@ -315,10 +352,17 @@ -- > type' "A" [bvar "a", bvar "b"] $ var "B" @@ var "b" @@ var "a" type' :: OccNameStr -> [HsTyVarBndr'] -> HsType' -> HsDecl' type' name vars t =+#if MIN_VERSION_ghc(9,10,0)+    noExt TyClD $ withPlaceHolder $ SynDecl [] (typeRdrName $ unqual name)+        (mkQTyVars vars)+        Prefix+        (mkLocated t)+#else     noExt TyClD $ withPlaceHolder $ withEpAnnNotUsed SynDecl (typeRdrName $ unqual name)         (mkQTyVars vars)         Prefix         (mkLocated t)+#endif  newOrDataType     :: NewOrData@@ -329,41 +373,65 @@     -> HsDecl' newOrDataType newOrData name vars conDecls derivs     = noExt TyClD $ withPlaceHolder $ withPlaceHolder $-        withEpAnnNotUsed DataDecl (typeRdrName $ unqual name)+#if MIN_VERSION_ghc(9,6,0)+#if MIN_VERSION_ghc(9,10,0)+        DataDecl [] (typeRdrName $ unqual name)             (mkQTyVars vars)             Prefix             $ noExt HsDataDefn-#if !MIN_VERSION_ghc(9,6,0)-                newOrData-#endif-                cxt                 Nothing                 Nothing-#if MIN_VERSION_ghc(9,6,0)-                (case newOrData of-                    NewType -> case conDecls of-                        [decl] -> NewTypeCon $ mkLocated decl-                        _ -> error "NewTypeCon with more than one decl"-                    DataType -> DataTypeCons False (map mkLocated conDecls)-                )  -#else-                (map mkLocated conDecls)-#endif-#if MIN_VERSION_ghc(9,4,0)-                (toHsDeriving $ map mkLocated derivs)+                Nothing+                (mkDataDefnCon newOrData conDecls)+                (map mkLocated derivs) #else-                (toHsDeriving $ map builtLoc derivs)+        withEpAnnNotUsed DataDecl (typeRdrName $ unqual name)+            (mkQTyVars vars)+            Prefix+            $ noExt HsDataDefn+                Nothing+                Nothing+                Nothing+                (mkDataDefnCon newOrData conDecls)+                (map mkLocated derivs) #endif   where-#if MIN_VERSION_ghc(9,2,0)-    cxt = Nothing-#else-    cxt = builtLoc []-#endif-#if MIN_VERSION_ghc(9,2,0)-    toHsDeriving = id+    mkDataDefnCon NewType [decl] = NewTypeCon $ mkLocated decl+    mkDataDefnCon NewType _ = error "NewTypeCon with more than one decl"+    mkDataDefnCon DataType decls = DataTypeCons False (map mkLocated decls)+#elif MIN_VERSION_ghc(9,4,0)+        withEpAnnNotUsed DataDecl (typeRdrName $ unqual name)+            (mkQTyVars vars)+            Prefix+            $ noExt HsDataDefn+                newOrData+                Nothing+                Nothing+                Nothing+                (map mkLocated conDecls)+                (map mkLocated derivs)+#elif MIN_VERSION_ghc(9,2,0)+        withEpAnnNotUsed DataDecl (typeRdrName $ unqual name)+            (mkQTyVars vars)+            Prefix+            $ noExt HsDataDefn+                newOrData+                Nothing+                Nothing+                Nothing+                (map mkLocated conDecls)+                (map builtLoc derivs) #else-    toHsDeriving = mkLocated+        withEpAnnNotUsed DataDecl (typeRdrName $ unqual name)+            (mkQTyVars vars)+            Prefix+            $ noExt HsDataDefn+                newOrData+                (builtLoc [])+                Nothing+                Nothing+                (map mkLocated conDecls)+                (mkLocated $ map builtLoc derivs) #endif  -- | A newtype declaration.@@ -426,10 +494,14 @@     $ RecCon $ mkLocated $ map mkLConDeclField fields   where     mkLConDeclField (n, f) =+#if MIN_VERSION_ghc(9,10,0)+        mkLocated $ ConDeclField []+                        [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n]+#elif MIN_VERSION_ghc(9,4,0)         mkLocated $ withEpAnnNotUsed ConDeclField-#if MIN_VERSION_ghc(9,4,0)                         [mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n] #else+        mkLocated $ withEpAnnNotUsed ConDeclField                         [builtLoc $ withPlaceHolder $ noExt FieldOcc $ valueRdrName $ unqual n] #endif                         (renderField f)@@ -481,13 +553,19 @@   where     wrap = case strictness f of         NoSrcStrict -> id+#if MIN_VERSION_ghc(9,10,0)+        s -> mkLocated . (HsBangTy [] $ noSourceText HsSrcBang NoSrcUnpack s)+#else         s -> mkLocated . (withEpAnnNotUsed HsBangTy $ noSourceText HsSrcBang NoSrcUnpack s)+#endif  renderCon98Decl :: OccNameStr -> HsConDeclDetails' -> ConDecl' renderCon98Decl name details =     conDeclH98 (typeRdrName $ unqual name) False [] Nothing details Nothing   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    conDeclH98 = ConDeclH98 []+#elif MIN_VERSION_ghc(9,2,0)     conDeclH98 = withEpAnnNotUsed ConDeclH98 #elif MIN_VERSION_ghc(8,6,0)     conDeclH98 n = noExt ConDeclH98 n . builtLoc@@ -500,7 +578,9 @@  derivingWay :: Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause' derivingWay way ts =-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+    HsDerivingClause [] (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     withEpAnnNotUsed HsDerivingClause (fmap builtLoc way) $ mkLocated $ derivClauseTys $ map sigType ts@@ -516,7 +596,9 @@ derivingStock :: [HsType'] -> HsDerivingClause' derivingStock = derivingWay (Just strat)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = StockStrategy []+#elif MIN_VERSION_ghc(9,2,0)     strat = withEpAnnNotUsed StockStrategy #else     strat = StockStrategy@@ -525,7 +607,9 @@ derivingNewtype :: [HsType'] -> HsDerivingClause' derivingNewtype = derivingWay (Just strat)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = NewtypeStrategy []+#elif MIN_VERSION_ghc(9,2,0)     strat = withEpAnnNotUsed NewtypeStrategy #else     strat = NewtypeStrategy@@ -534,7 +618,9 @@ derivingAnyclass :: [HsType'] -> HsDerivingClause' derivingAnyclass = derivingWay (Just strat)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = AnyclassStrategy []+#elif MIN_VERSION_ghc(9,2,0)     strat = withEpAnnNotUsed AnyclassStrategy #else     strat = AnyclassStrategy@@ -550,7 +636,9 @@ derivingVia :: HsType' -> [HsType'] -> HsDerivingClause' derivingVia t = derivingWay (Just $ strat $ sigType t)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = ViaStrategy . XViaStrategyPs []+#elif MIN_VERSION_ghc(9,2,0)     strat = ViaStrategy . withEpAnnNotUsed XViaStrategyPs #else     strat = ViaStrategy@@ -563,7 +651,9 @@ standaloneDerivingStock :: HsType' -> HsDecl' standaloneDerivingStock = standaloneDerivingWay (Just strat)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = StockStrategy []+#elif MIN_VERSION_ghc(9,2,0)     strat = withEpAnnNotUsed StockStrategy #else     strat = StockStrategy@@ -572,7 +662,9 @@ standaloneDerivingNewtype :: HsType' -> HsDecl' standaloneDerivingNewtype = standaloneDerivingWay (Just strat)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = NewtypeStrategy []+#elif MIN_VERSION_ghc(9,2,0)     strat = withEpAnnNotUsed NewtypeStrategy #else     strat = NewtypeStrategy@@ -581,7 +673,9 @@ standaloneDerivingAnyclass :: HsType' -> HsDecl' standaloneDerivingAnyclass = standaloneDerivingWay (Just strat)   where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+    strat = AnyclassStrategy []+#elif MIN_VERSION_ghc(9,2,0)     strat = withEpAnnNotUsed AnyclassStrategy #else     strat = AnyclassStrategy@@ -590,7 +684,9 @@ standaloneDerivingWay :: Maybe DerivStrategy' -> HsType' -> HsDecl' standaloneDerivingWay way ty = noExt DerivD derivDecl   where derivDecl =-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+          DerivDecl (Nothing, []) (hsWC $ sigType ty) (fmap mkLocated way) Nothing+#elif MIN_VERSION_ghc(9,4,0)           withEpAnnNotUsed DerivDecl (hsWC $ sigType ty) (fmap mkLocated way) Nothing #else           withEpAnnNotUsed DerivDecl (hsWC $ sigType ty) (fmap builtLoc way) Nothing@@ -609,8 +705,13 @@ -- > patSynSigs ["F", "G"] $ var "T" patSynSigs :: [OccNameStr] -> HsType' -> HsDecl' patSynSigs names t =+#if MIN_VERSION_ghc(9,10,0)+    sigB $ PatSynSig noAnn (map (typeRdrName . unqual) names)+        $ sigType t+#else     sigB $ withEpAnnNotUsed PatSynSig (map (typeRdrName . unqual) names)         $ sigType t+#endif  -- | Declares a pattern signature and its type. --@@ -628,7 +729,14 @@ -- > ===== -- > patSynBind "F" ["a", "b"] $ conP "G" [bvar "b", bvar "a"] patSynBind :: OccNameStr -> [OccNameStr] -> Pat' -> HsDecl'+#if MIN_VERSION_ghc(9,10,0) patSynBind n ns p = bindB $ noExt PatSynBind+                    $ withPlaceHolder (PSB [] (valueRdrName $ unqual n))+                        (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))                         (builtPat p)@@ -639,4 +747,4 @@ #else     prefixCon' = PrefixCon #endif-+#endif
src/GHC/SourceGen/Expr.hs view
@@ -30,7 +30,11 @@  import GHC.Hs.Expr import GHC.Hs.Extension (GhcPs)-#if MIN_VERSION_ghc(9,6,0)+#if MIN_VERSION_ghc(9,10,0)+import GHC.Hs.Expr (EpAnnHsCase (..))+import GHC.Parser.Annotation (EpToken(..), noAnn, noSpanAnchor)+import GHC.Types.SourceText (SourceText(NoSourceText))+#elif MIN_VERSION_ghc(9,6,0) import GHC.Hs.Extension (noHsTok) import GHC.Types.SourceText (SourceText(NoSourceText)) #endif@@ -71,7 +75,9 @@ overLabel :: String -> HsExpr' overLabel = hsOverLabel . fromString   where-#if MIN_VERSION_ghc(9,6,0)+#if 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)     hsOverLabel = withEpAnnNotUsed HsOverLabel@@ -80,7 +86,9 @@ #endif  let' :: [RawValBind] -> HsExpr' -> HsExpr'-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+let' binds e = HsLet (EpTok noSpanAnchor, EpTok noSpanAnchor) (toHsLocalBinds $ valBinds binds) $ mkLocated e+#elif MIN_VERSION_ghc(9,4,0) let' binds e = withEpAnnNotUsed HsLet mkToken (toHsLocalBinds $ valBinds binds) mkToken $ mkLocated e #else let' binds e = withEpAnnNotUsed HsLet (toHsLocalBinds $ valBinds binds) $ mkLocated e@@ -93,14 +101,27 @@ #endif  case' :: HsExpr' -> [RawMatch] -> HsExpr'+#if MIN_VERSION_ghc(9,10,0)+case' e matches = HsCase ann (mkLocated e)+                    $ matchGroup CaseAlt matches+  where+    ann = EpAnnHsCase noSpanAnchor noSpanAnchor []+#else case' e matches = withEpAnnNotUsed HsCase (mkLocated e)                     $ matchGroup CaseAlt matches+#endif  lambda :: [Pat'] -> HsExpr' -> HsExpr'+#if MIN_VERSION_ghc(9,10,0)+lambda ps e = HsLam [] 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,4,0)+#if MIN_VERSION_ghc(9,10,0)+lambdaCase = HsLam [] LamCase . matchGroup CaseAlt+#elif MIN_VERSION_ghc(9,4,0) lambdaCase = withEpAnnNotUsed HsLamCase LamCase . matchGroup CaseAlt #else lambdaCase = withEpAnnNotUsed HsLamCase . matchGroup CaseAlt@@ -111,8 +132,11 @@                 (mkLocated x)                 (mkLocated y)                 (mkLocated z)-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+                noAnn+#elif MIN_VERSION_ghc(9,2,0)                 EpAnnNotUsed+#else #endif  -- | A MultiWayIf expression.@@ -127,7 +151,9 @@ -- >     , guardedStmt (var "otherwise") $ rhs (string "h") -- >     ] multiIf :: [GuardedExpr] -> HsExpr'-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+multiIf = withPlaceHolder (HsMultiIf []) . map mkLocated+#elif MIN_VERSION_ghc(9,4,0) multiIf = withPlaceHolder (withEpAnnNotUsed HsMultiIf) . map mkLocated #else multiIf = withPlaceHolder (withEpAnnNotUsed HsMultiIf) . map builtLoc@@ -144,7 +170,9 @@ -- > do' [bvar "x" <-- var "act", stmt $ var "return" @@ var "x"] do' :: [Stmt'] -> HsExpr' do' = withPlaceHolder-#if MIN_VERSION_ghc(9,0,0)+#if MIN_VERSION_ghc(9,10,0)+        . HsDo noAnn (DoExpr Nothing)+#elif MIN_VERSION_ghc(9,0,0)         . withEpAnnNotUsed HsDo (DoExpr Nothing) #else         . noExt HsDo DoExpr@@ -180,8 +208,13 @@ #else         ret = False #endif+#if MIN_VERSION_ghc(9,10,0)+     in withPlaceHolder . HsDo noAnn ListComp . mkLocated . map mkLocated $+            stmts ++ [lastStmt]+#else      in withPlaceHolder . withEpAnnNotUsed HsDo ListComp . mkLocated . map mkLocated $             stmts ++ [lastStmt]+#endif  -- | A type constraint on an expression. --@@ -189,7 +222,9 @@ -- > ===== -- > var "e" @::@ var "t" (@::@) :: HsExpr' -> HsType' -> HsExpr'-#if MIN_VERSION_ghc(8,8,0)+#if MIN_VERSION_ghc(9,10,0)+e @::@ t = ExprWithTySig [] (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) e @::@ t = ExprWithTySig (sigWcType t) (builtLoc e)@@ -204,7 +239,9 @@ -- > ===== -- > var "f" @@ var "Int" tyApp :: HsExpr' -> HsType' -> HsExpr'-#if MIN_VERSION_ghc(9,6,0)+#if MIN_VERSION_ghc(9,10,0)+tyApp e t = HsAppType (EpTok noSpanAnchor) e' t'+#elif MIN_VERSION_ghc(9,6,0) tyApp e t = noExt HsAppType e' noHsTok t' #elif MIN_VERSION_ghc(9,2,0) tyApp e t = HsAppType builtSpan e' t'@@ -225,7 +262,11 @@ -- > ===== -- > recordConE "A" [("x", var "y")] recordConE :: RdrNameStr -> [(RdrNameStr, HsExpr')] -> HsExpr'+#if MIN_VERSION_ghc(9,10,0)+recordConE c fs = (withPlaceHolder $ RecordCon [] (valueRdrName c))+#else recordConE c fs = (withPlaceHolder $ withEpAnnNotUsed RecordCon (valueRdrName c))+#endif #if !MIN_VERSION_ghc(8,6,0)                     noPostTcExpr #endif@@ -234,12 +275,19 @@   where     recField :: (RdrNameStr, HsExpr') -> LHsRecField' LHsExpr'     recField (f, e) =-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)         mkLocated HsFieldBind             { hfbLHS =                   mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f             , hfbRHS = mkLocated e             , hfbPun = False+            , hfbAnn = []+#elif MIN_VERSION_ghc(9,4,0)+        mkLocated HsFieldBind+            { hfbLHS =+                  mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f+            , hfbRHS = mkLocated e+            , hfbPun = False             , hfbAnn = EpAnnNotUsed #else         mkLocated HsRecField@@ -268,18 +316,31 @@ -- > var "f" @@ recordUpd (var "x") [("a", var "b")] recordUpd :: HsExpr' -> [(RdrNameStr, HsExpr')] -> HsExpr' recordUpd e fs =+#if MIN_VERSION_ghc(9,10,0)     withPlaceHolder4+       $ RecordUpd [] (parenthesizeExprForApp $ mkLocated e)+       $ toRecordUpdFields $ map mkField fs+#else+    withPlaceHolder4        $ withEpAnnNotUsed RecordUpd (parenthesizeExprForApp $ mkLocated e)        $ toRecordUpdFields $ map mkField fs+#endif   where     mkField :: (RdrNameStr, HsExpr') -> LHsRecUpdField'     mkField (f, e') =-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)         mkLocated HsFieldBind             { hfbLHS =                 mkLocated $ withPlaceHolder $ noExt Ambiguous $ valueRdrName f             , hfbRHS = mkLocated e'             , hfbPun = False+            , hfbAnn = []+#elif MIN_VERSION_ghc(9,4,0)+        mkLocated HsFieldBind+            { hfbLHS =+                mkLocated $ withPlaceHolder $ noExt Ambiguous $ valueRdrName f+            , hfbRHS = mkLocated e'+            , hfbPun = False             , hfbAnn = EpAnnNotUsed #else         mkLocated HsRecField@@ -304,7 +365,9 @@  arithSeq :: ArithSeqInfo GhcPs -> HsExpr' arithSeq =-#if MIN_VERSION_ghc(8,6,0)+#if MIN_VERSION_ghc(9,10,0)+    ArithSeq [] Nothing+#elif MIN_VERSION_ghc(8,6,0)     withEpAnnNotUsed ArithSeq Nothing #else     ArithSeq noPostTcExpr Nothing
src/GHC/SourceGen/Expr/Internal.hs view
@@ -17,6 +17,10 @@ import GHC.SourceGen.Lit.Internal import GHC.SourceGen.Syntax.Internal +#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (EpToken (..), noSpanAnchor)+#endif+ #if MIN_VERSION_ghc(9,4,0) import Language.Haskell.Syntax.Extension #endif@@ -31,7 +35,9 @@     | otherwise = e  parExpr :: LHsExpr' -> LHsExpr'-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+parExpr e = mkLocated $ HsPar (EpTok noSpanAnchor, EpTok noSpanAnchor) e+#elif MIN_VERSION_ghc(9,4,0) parExpr e = mkLocated $ withEpAnnNotUsed HsPar mkToken e mkToken #else parExpr = mkLocated . withEpAnnNotUsed HsPar@@ -49,7 +55,9 @@     HsLit WILD_EXT l -> litNeedsParen l     HsOverLit WILD_EXT l -> overLitNeedsParen l     HsLam{} -> True+#if !MIN_VERSION_ghc(9,10,0)     HsLamCase{} -> True+#endif     OpApp{} -> True     NegApp{} -> True     HsCase{} -> True
src/GHC/SourceGen/Lit.hs view
@@ -39,15 +39,24 @@     overLit :: HsOverLit' -> e  instance HasLit HsExpr' where+#if MIN_VERSION_ghc(9,10,0)+    lit = noExt HsLit+    overLit = noExt HsOverLit+#else     lit = withEpAnnNotUsed HsLit     overLit = withEpAnnNotUsed HsOverLit+#endif  instance HasLit Pat' where     lit = noExt LitPat+#if MIN_VERSION_ghc(9,10,0)     overLit l = withPlaceHolder-#if MIN_VERSION_ghc(9,4,0)+                    $ NPat [] (mkLocated l) Nothing noSyntaxExpr+#elif MIN_VERSION_ghc(9,4,0)+    overLit l = withPlaceHolder                     $ withEpAnnNotUsed NPat (mkLocated l) Nothing noSyntaxExpr #else+    overLit l = withPlaceHolder                     $ withEpAnnNotUsed NPat (builtLoc l) Nothing noSyntaxExpr #endif 
src/GHC/SourceGen/Module.hs view
@@ -43,8 +43,11 @@ #if MIN_VERSION_ghc(9,2,0)     , EpAnn(..) #endif+#if MIN_VERSION_ghc(9,6,0) && !MIN_VERSION_ghc(9,10,0)+    , LayoutInfo (NoLayoutInfo)+#endif #if MIN_VERSION_ghc(9,6,0)-    , hsmodDeprecMessage, hsmodHaddockModHeader, hsmodAnn, AnnKeywordId, XModulePs (XModulePs, hsmodLayout), noAnn, LayoutInfo (NoLayoutInfo), GhcPs, XImportDeclPass (XImportDeclPass, ideclAnn), SrcSpanAnnA, noExtField+    , hsmodDeprecMessage, hsmodHaddockModHeader, hsmodAnn, AnnKeywordId, XModulePs (XModulePs, hsmodLayout), noAnn, GhcPs, XImportDeclPass (XImportDeclPass, ideclAnn), SrcSpanAnnA, noExtField #endif     ) #if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0)@@ -59,7 +62,11 @@ #if MIN_VERSION_ghc(9,4,0) import GHC.Types.PkgQual (RawPkgQual(..)) #endif+#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (EpLayout (..), noAnn)+#endif + import GHC.SourceGen.Syntax.Internal import GHC.SourceGen.Name.Internal import GHC.SourceGen.Lit.Internal (noSourceText)@@ -84,7 +91,11 @@ #if MIN_VERSION_ghc(9,6,0)     , hsmodExt = XModulePs       { hsmodAnn = noAnn+#if MIN_VERSION_ghc(9,10,0)+      , hsmodLayout = EpNoLayout+#else       , hsmodLayout = NoLayoutInfo+#endif       , hsmodDeprecMessage = Nothing       , hsmodHaddockModHeader = Nothing } #else@@ -135,8 +146,14 @@ #endif             Nothing Nothing   where-#if MIN_VERSION_ghc(9,6,0)+#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@@ -177,7 +194,11 @@ -- > ===== -- > thingAll "A" thingAll :: RdrNameStr -> IE'+#if MIN_VERSION_ghc(9,10,0)+thingAll n = IEThingAll (Nothing, []) (wrappedName n) Nothing+#else thingAll = withEpAnnNotUsed' IEThingAll . wrappedName+#endif  -- | Exports specific methods and/or constructors. --@@ -185,6 +206,9 @@ -- > ===== -- > 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+#else thingWith n cs = withEpAnnNotUsed' IEThingWith (wrappedName n) NoIEWildcard                     (map (wrappedName . unqual) cs) #if !MIN_VERSION_ghc(9,2,0)@@ -193,7 +217,7 @@                     -- constructors.                     [] #endif-+#endif -- TODO: support "mixed" syntax with both ".." and explicit names.  #if MIN_VERSION_ghc(9,6,0)@@ -212,21 +236,24 @@ -- > ===== -- > moduleContents "M" moduleContents :: ModuleNameStr -> IE'+#if MIN_VERSION_ghc(9,10,0)+moduleContents n = IEModuleContents (Nothing, []) (mkLocated (unModuleNameStr n))+#else moduleContents = withEpAnnNotUsed' IEModuleContents . mkLocated . unModuleNameStr-+#endif -#if MIN_VERSION_ghc(9,8,0)+#if MIN_VERSION_ghc(9,10,0)+-- withEpAnnNotUsed' is not necessary for newer versions.+#elif MIN_VERSION_ghc(9,8,0) withEpAnnNotUsed' :: ((Maybe x, EpAnn ann) -> a) -> a withEpAnnNotUsed' = ($ (Nothing, EpAnnNotUsed))-#else--#if MIN_VERSION_ghc(9,2,0)+#elif MIN_VERSION_ghc(9,2,0) withEpAnnNotUsed' :: (EpAnn ann -> a) -> a+withEpAnnNotUsed' = withEpAnnNotUsed #elif MIN_VERSION_ghc(8,6,0) withEpAnnNotUsed' :: (NoExtField -> a) -> a+withEpAnnNotUsed' = withEpAnnNotUsed #else withEpAnnNotUsed' :: a -> a-#endif withEpAnnNotUsed' = withEpAnnNotUsed- #endif
src/GHC/SourceGen/Overloaded.hs view
@@ -39,7 +39,14 @@     , Pat(..)     , HsTupArg(..)     , HsTupleSort(..)+#if MIN_VERSION_ghc(9,10,0)+    , EpToken (..)+    , noSpanAnchor+#endif     )+#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (AnnList (..), AnnParen (AnnParen), ParenType (AnnParens), noAnn)+#endif #if MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic (Boxity(..)) import GHC.Core.DataCon (dataConName)@@ -62,22 +69,35 @@ class Par e where     par :: e -> e +#if MIN_VERSION_ghc(9,10,0)+mkParToken :: (EpToken "(", EpToken ")")+mkParToken = (EpTok noSpanAnchor, EpTok noSpanAnchor)+#endif+ instance Par HsExpr' where-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+    par p = HsPar mkParToken (mkLocated p)+#elif MIN_VERSION_ghc(9,4,0)     par p = withEpAnnNotUsed HsPar mkToken (mkLocated p) mkToken #else     par = withEpAnnNotUsed HsPar . mkLocated #endif  instance Par Pat' where-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+    par p = ParPat mkParToken (builtPat p)+#elif MIN_VERSION_ghc(9,4,0)     par p = withEpAnnNotUsed ParPat mkToken (builtPat p) mkToken #else     par = withEpAnnNotUsed ParPat . builtPat #endif  instance Par HsType' where+#if MIN_VERSION_ghc(9,10,0)+    par = HsParTy (AnnParen AnnParens noSpanAnchor noSpanAnchor) . mkLocated+#else     par = withEpAnnNotUsed HsParTy . mkLocated+#endif  -- | A class for term application. --@@ -141,7 +161,14 @@ infixl 2 @@  instance App HsExpr' where+#if MIN_VERSION_ghc(9,10,0)     op x o y+        = OpApp []+            (parenthesizeExprForOp $ mkLocated x)+            (mkLocated $ var o)+            (parenthesizeExprForOp $ mkLocated y)+#else+    op x o y         = withEpAnnNotUsed OpApp             (parenthesizeExprForOp $ mkLocated x)             (mkLocated $ var o)@@ -149,12 +176,22 @@             PlaceHolder #endif             (parenthesizeExprForOp $ mkLocated y)+#endif+#if MIN_VERSION_ghc(9,10,0)+    x @@ y = noExt HsApp (parenthesizeExprForOp $ mkLocated x)+                (parenthesizeExprForApp $ mkLocated y)+#else     x @@ y = withEpAnnNotUsed HsApp (parenthesizeExprForOp $ mkLocated x)                 (parenthesizeExprForApp $ mkLocated y)+#endif  instance App HsType' where     op x o y-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+        = HsOpTy [] notPromoted (parenthesizeTypeForOp $ mkLocated x)+                (typeRdrName o)+                (parenthesizeTypeForOp $ mkLocated y)+#elif MIN_VERSION_ghc(9,4,0)         = withEpAnnNotUsed HsOpTy notPromoted (parenthesizeTypeForOp $ mkLocated x)                 (typeRdrName o)                 (parenthesizeTypeForOp $ mkLocated y)@@ -176,7 +213,12 @@ unboxedTuple = tupleOf Unboxed  instance HasTuple HsExpr' where++#if MIN_VERSION_ghc(9,10,0)     tupleOf b ts =+        ExplicitTuple [] (map (noExt Present . mkLocated) ts) b+#else+    tupleOf b ts =         explicitTuple             (map (withEpAnnNotUsed Present . mkLocated) ts)             b@@ -186,13 +228,18 @@ #else         explicitTuple = noExt ExplicitTuple . map builtLoc #endif+#endif     unit = noExt HsVar unitDataConName  unitDataConName :: LIdP 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+#else     tupleOf b = withEpAnnNotUsed HsTupleTy b' . map mkLocated+#endif         where             b' = case b of                     Unboxed -> HsUnboxedTuple@@ -203,9 +250,12 @@  instance HasTuple Pat' where     tupleOf b ps =+#if MIN_VERSION_ghc(9,10,0)+        TuplePat [] (map builtPat ps) b+#elif MIN_VERSION_ghc(8,6,0)         withEpAnnNotUsed TuplePat (map builtPat ps) b-#if !MIN_VERSION_ghc(8,6,0)-        []+#else+        withEpAnnNotUsed TuplePat (map builtPat ps) b [] #endif     unit = noExt VarPat unitDataConName @@ -233,7 +283,9 @@ instance HasList HsExpr' where     list = withPlaceHolder (withEpAnnNotUsed explicitList) . map mkLocated       where-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+        explicitList = ExplicitList noAnn+#elif MIN_VERSION_ghc(9,2,0)         explicitList = ExplicitList #else         explicitList x = ExplicitList x Nothing@@ -242,7 +294,9 @@     cons = noExt HsVar $ mkLocated consDataCon_RDR  instance HasList Pat' where-#if MIN_VERSION_ghc(8,6,0)+#if MIN_VERSION_ghc(9,10,0)+    list = ListPat noAnn . map builtPat+#elif MIN_VERSION_ghc(8,6,0)     list = withEpAnnNotUsed ListPat . map builtPat #else     list ps = ListPat (map builtPat ps) PlaceHolder Nothing@@ -276,20 +330,30 @@     bvar = var . UnqualStr  instance Var HsType' where+#if MIN_VERSION_ghc(9,10,0)+    var = HsTyVar [] notPromoted . typeRdrName+#else     var = withEpAnnNotUsed HsTyVar notPromoted . typeRdrName+#endif  instance BVar HsType' where     bvar = var . UnqualStr -#if MIN_VERSION_ghc(9,0,0)+#if MIN_VERSION_ghc(9,10,0) instance BVar HsTyVarBndr' where-#if MIN_VERSION_ghc(9,8,0)+    bvar = UserTyVar [] (noExt HsBndrRequired) . typeRdrName . UnqualStr+instance BVar HsTyVarBndrS' where+    bvar = UserTyVar [] SpecifiedSpec . typeRdrName . UnqualStr+#elif MIN_VERSION_ghc(9,8,0)+instance BVar HsTyVarBndr' where     bvar = withEpAnnNotUsed UserTyVar HsBndrRequired . typeRdrName . UnqualStr-#else-    bvar = withEpAnnNotUsed UserTyVar () . typeRdrName . UnqualStr-#endif instance BVar HsTyVarBndrS' where     bvar = withEpAnnNotUsed UserTyVar SpecifiedSpec . typeRdrName . UnqualStr+#elif MIN_VERSION_ghc(9,0,0)+instance BVar HsTyVarBndr' where+  bvar = withEpAnnNotUsed UserTyVar () . typeRdrName . UnqualStr+instance BVar HsTyVarBndrS' where+    bvar = withEpAnnNotUsed UserTyVar SpecifiedSpec . typeRdrName . UnqualStr #else instance BVar HsTyVarBndr' where     bvar = withEpAnnNotUsed UserTyVar . typeRdrName . UnqualStr@@ -298,14 +362,18 @@ instance Var IE' where     var n = ie_var $ mkLocated $ ie_name $ exportRdrName n       where+#if MIN_VERSION_ghc(9,10,0)+        ie_var x =+          IEVar Nothing x Nothing+#elif MIN_VERSION_ghc(9,8,0)         ie_var =-#if MIN_VERSION_ghc(9,8,0)           IEVar Nothing #else+        ie_var =           noExt IEVar #endif -        ie_name = +        ie_name = #if MIN_VERSION_ghc(9,6,0)           noExt IEName #else
src/GHC/SourceGen/Pat.hs view
@@ -26,10 +26,12 @@ import GHC.SourceGen.Syntax.Internal import GHC.SourceGen.Type.Internal (patSigType) -#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (EpAnn(..), EpToken(..), noAnn, noSpanAnchor)+#elif MIN_VERSION_ghc(9,2,0) import GHC.Parser.Annotation (EpAnn(..)) #endif-#if MIN_VERSION_ghc(9,6,0)+#if MIN_VERSION_ghc(9,6,0) && !MIN_VERSION_ghc(9,10,0) import GHC (noHsTok) #endif @@ -44,11 +46,17 @@ -- > asP "a" (var "B") asP :: RdrNameStr -> Pat' -> Pat' v `asP` p =+#if MIN_VERSION_ghc(9,10,0)+  AsPat (EpTok noSpanAnchor) (valueRdrName v)+    (builtPat $ parenthesize p)+#elif MIN_VERSION_ghc(9,6,0)   withEpAnnNotUsed AsPat (valueRdrName v)-#if MIN_VERSION_ghc(9,6,0)-  noHsTok+    noHsTok+    (builtPat $ parenthesize p)+#else+  withEpAnnNotUsed AsPat (valueRdrName v)+    (builtPat $ parenthesize p) #endif-  (builtPat $ parenthesize p)  -- | A pattern constructor. --@@ -58,7 +66,9 @@ conP :: RdrNameStr -> [Pat'] -> Pat' conP c = conPat (valueRdrName c) . prefixCon . map (builtPat . parenthesize)   where-#if MIN_VERSION_ghc(9,0,0)+#if MIN_VERSION_ghc(9,10,0)+    conPat = ConPat []+#elif MIN_VERSION_ghc(9,0,0)     conPat = withEpAnnNotUsed ConPat #else     conPat = ConPatIn@@ -79,7 +89,9 @@  recordConP :: RdrNameStr -> [(RdrNameStr, Pat')] -> Pat' recordConP c fs =-#if MIN_VERSION_ghc(9,0,0)+#if MIN_VERSION_ghc(9,10,0)+  ConPat []+#elif MIN_VERSION_ghc(9,0,0)   withEpAnnNotUsed ConPat #else   ConPatIn@@ -89,8 +101,14 @@   where     mkRecField :: (RdrNameStr, Pat') -> LHsRecField' LPat'     mkRecField (f, p) =-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)         mkLocated $ HsFieldBind+            { hfbAnn = noAnn+            , hfbLHS = mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f+            , hfbRHS = builtPat p+            , hfbPun = False      +#elif MIN_VERSION_ghc(9,4,0)+        mkLocated $ HsFieldBind             { hfbAnn = EpAnnNotUsed             , hfbLHS = mkLocated $ withPlaceHolder $ noExt FieldOcc $ valueRdrName f             , hfbRHS = builtPat p@@ -113,7 +131,11 @@ -- > ===== -- > strictP (bvar x) strictP :: Pat' -> Pat'+#if MIN_VERSION_ghc(9,10,0)+strictP = BangPat [] . builtPat . parenthesize+#else strictP = withEpAnnNotUsed BangPat . builtPat . parenthesize+#endif  -- | A lazy pattern match. --@@ -121,7 +143,11 @@ -- > ===== -- > lazyP (conP "A" [bvar x]) lazyP :: Pat' -> Pat'+#if MIN_VERSION_ghc(9,10,0)+lazyP = LazyPat [] . builtPat . parenthesize+#else lazyP = withEpAnnNotUsed LazyPat . builtPat . parenthesize+#endif  -- | A pattern type signature --@@ -129,7 +155,9 @@ -- > ===== -- > sigPat (bvar "x") (var "y") sigP :: Pat' -> HsType' -> Pat'-#if MIN_VERSION_ghc(8,8,0)+#if MIN_VERSION_ghc(9,10,0)+sigP p t = SigPat [] (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) sigP p t = SigPat (patSigType t) (builtPat p)
src/GHC/SourceGen/Pat/Internal.hs view
@@ -2,6 +2,9 @@ module GHC.SourceGen.Pat.Internal where  import GHC.Hs.Pat (Pat(..))+#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (EpToken(..), noSpanAnchor)+#endif #if MIN_VERSION_ghc(9,0,0) import GHC.Hs.Type (HsConDetails(..)) import GHC.Types.SrcLoc (unLoc)@@ -51,7 +54,9 @@ needsPar _ = False  parPat :: Pat' -> Pat'-#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,10,0)+parPat p = ParPat (EpTok noSpanAnchor, EpTok noSpanAnchor) (builtPat p)+#elif MIN_VERSION_ghc(9,4,0) parPat p = withEpAnnNotUsed ParPat mkToken (builtPat p) mkToken #else parPat = withEpAnnNotUsed ParPat . builtPat
src/GHC/SourceGen/Syntax/Internal.hs view
@@ -55,6 +55,9 @@ #endif import GHC.Hs.Decls (HsDerivingClause) import GHC.Hs.Pat+#if MIN_VERSION_ghc(9,10,0)+import Language.Haskell.Syntax.Extension (NoGhcTc)+#endif #if MIN_VERSION_ghc(9,0,0) import GHC.Types.SrcLoc (SrcSpan, Located, GenLocated(..), mkGeneralSrcSpan) #else@@ -128,7 +131,10 @@ noExtOrPlaceHolder = withPlaceHolder #endif -#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+withEpAnnNotUsed :: a -> a+withEpAnnNotUsed = id+#elif MIN_VERSION_ghc(9,2,0) withEpAnnNotUsed :: (EpAnn ann -> a) -> a withEpAnnNotUsed = ($ EpAnnNotUsed) #elif MIN_VERSION_ghc(8,6,0)@@ -139,7 +145,10 @@ withEpAnnNotUsed = id #endif -#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+withNoAnnSortKey :: (AnnSortKey tag -> a) -> a+withNoAnnSortKey = ($ NoAnnSortKey)+#elif MIN_VERSION_ghc(9,2,0) withNoAnnSortKey :: (AnnSortKey -> a) -> a withNoAnnSortKey = ($ NoAnnSortKey) #elif MIN_VERSION_ghc(8,6,0)@@ -183,19 +192,24 @@ builtLoc :: e -> Located e builtLoc = L builtSpan -#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+type SrcSpanAnn ann = EpAnn ann+#elif MIN_VERSION_ghc(9,2,0) type SrcSpanAnn ann = GHC.SrcSpanAnn' (EpAnn ann) #else type SrcSpanAnn ann = SrcSpan #endif ++#if MIN_VERSION_ghc(9,10,0)+mkLocated :: (NoAnn ann) => a -> GenLocated (SrcSpanAnn ann) a+mkLocated = L (EpAnn (spanAsAnchor builtSpan) noAnn emptyComments)+#elif MIN_VERSION_ghc(9,2,0) mkLocated :: a -> GenLocated (SrcSpanAnn ann) a-mkLocated = L (toAnn builtSpan)-  where-#if MIN_VERSION_ghc(9,2,0)-    toAnn = SrcSpanAnn EpAnnNotUsed+mkLocated = L (SrcSpanAnn EpAnnNotUsed builtSpan) #else-    toAnn = id+mkLocated :: a -> GenLocated (SrcSpanAnn ann) a+mkLocated = L builtSpan #endif  -- In GHC-8.8.* (but not >=8.10 or <=8.6), source locations for Pat aren't@@ -306,7 +320,9 @@ type HsLocalBinds' = HsLocalBinds GhcPs type HsValBinds' = HsValBinds GhcPs type Sig' = Sig GhcPs-#if MIN_VERSION_ghc(9,0,0)+#if MIN_VERSION_ghc(9,10,0)+type HsMatchContext' = HsMatchContext (GHC.LIdP (NoGhcTc GhcPs))+#elif MIN_VERSION_ghc(9,0,0) type HsMatchContext' = HsMatchContext GhcPs #else type HsMatchContext' = HsMatchContext RdrName@@ -356,12 +372,12 @@ type LIdP = Located (GHC.IdP GHC.GhcPs) #endif -#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,4,0) && !MIN_VERSION_ghc(9,10,0) mkUniToken :: GenLocated TokenLocation (GHC.HsUniToken t u) mkUniToken = L NoTokenLoc GHC.HsNormalTok #endif -#if MIN_VERSION_ghc(9,4,0)+#if MIN_VERSION_ghc(9,4,0) && !MIN_VERSION_ghc(9,10,0) mkToken :: GenLocated TokenLocation (GHC.HsToken t) mkToken = L NoTokenLoc GHC.HsTok #endif
src/GHC/SourceGen/Type.hs view
@@ -40,7 +40,11 @@  -- | A promoted name, for example from the @DataKinds@ extension. tyPromotedVar :: RdrNameStr -> HsType'+#if MIN_VERSION_ghc(9,10,0)+tyPromotedVar = HsTyVar [] promoted . typeRdrName+#else tyPromotedVar = withEpAnnNotUsed HsTyVar promoted . typeRdrName+#endif  stringTy :: String -> HsType' stringTy = noExt HsTyLit . noSourceText HsStrTy . fromString@@ -49,15 +53,27 @@ numTy = noExt HsTyLit . noSourceText HsNumTy  listTy :: HsType' -> HsType'+#if MIN_VERSION_ghc(9,10,0)+listTy = HsListTy (AnnParen AnnParens noSpanAnchor noSpanAnchor) . mkLocated+#else listTy = withEpAnnNotUsed HsListTy . mkLocated+#endif  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+#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+#else tuplePromotedTy = withPlaceHolders (withEpAnnNotUsed HsExplicitTupleTy) . map mkLocated+#endif  -- | A function type. --@@ -65,13 +81,20 @@ -- > ===== -- > var "a" --> var "b" (-->) :: HsType' -> HsType' -> HsType'-a --> b = withEpAnnNotUsed HsFunTy-#if MIN_VERSION_ghc(9,4,0)+a --> b =+#if 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)-#endif          (parenthesizeTypeForFun $ mkLocated a) (mkLocated b)+#endif  infixr 0 --> @@ -81,16 +104,30 @@ -- > ===== -- > forall' [bvar "a"] $ var "T" @@ var "a" forall' :: [HsTyVarBndrS'] -> HsType' -> HsType'+#if MIN_VERSION_ghc(9,10,0)+forall' ts t =+    HsForAllTy+        NoExtField+        (mkHsForAllInvisTele ann (map mkLocated ts))+        (mkLocated t)+  where+    ann = EpAnn noSpanAnchor (noAnn, noAnn) emptyComments+#elif MIN_VERSION_ghc(9,2,0) forall' ts = noExt hsForAllTy (map mkLocated ts) . mkLocated   where-#if MIN_VERSION_ghc(9,2,0)     hsForAllTy x = HsForAllTy x . withEpAnnNotUsed mkHsForAllInvisTele #elif MIN_VERSION_ghc(9,0,0)+forall' ts = noExt hsForAllTy (map mkLocated ts) . mkLocated+  where     hsForAllTy x = HsForAllTy x . mkHsForAllInvisTele #elif MIN_VERSION_ghc(8,10,0)+forall' ts = noExt hsForAllTy (map mkLocated ts) . mkLocated+  where     fvf = ForallInvis -- "Invisible" forall, i.e., with a dot     hsForAllTy x = HsForAllTy x fvf #else+forall' ts = noExt hsForAllTy (map mkLocated ts) . mkLocated+  where     hsForAllTy = HsForAllTy #endif @@ -103,7 +140,7 @@ (==>) cs = hsQualTy (mkLocated (map mkLocated cs)) . mkLocated   where #if MIN_VERSION_ghc(9,4,0)-    hsQualTy = noExt HsQualTy +    hsQualTy = noExt HsQualTy #elif MIN_VERSION_ghc(9,2,0)     hsQualTy = noExt HsQualTy . Just #else@@ -118,10 +155,18 @@ -- > ===== -- > kindedVar "x" (var "A") kindedVar :: OccNameStr -> HsType' -> HsTyVarBndr'-kindedVar v t = withEpAnnNotUsed KindedTyVar-#if MIN_VERSION_ghc(9,8,0)+kindedVar v t =+#if MIN_VERSION_ghc(9,10,0)+            KindedTyVar+                []+                (noExt HsBndrRequired)+                (typeRdrName $ UnqualStr v) (mkLocated t)+#elif MIN_VERSION_ghc(9,8,0)+            withEpAnnNotUsed KindedTyVar                 HsBndrRequired+                (typeRdrName $ UnqualStr v) (mkLocated t) #elif MIN_VERSION_ghc(9,0,0)+            withEpAnnNotUsed KindedTyVar                 ()-#endif                 (typeRdrName $ UnqualStr v) (mkLocated t)+#endif
src/GHC/SourceGen/Type/Internal.hs view
@@ -17,6 +17,10 @@ import SrcLoc (unLoc) #endif +#if MIN_VERSION_ghc(9,10,0)+import GHC.Parser.Annotation (AnnParen (AnnParen), ParenType (AnnParens), noAnn, noSpanAnchor)+#endif+ import GHC.SourceGen.Syntax.Internal  mkQTyVars :: [HsTyVarBndr'] -> LHsQTyVars'@@ -63,7 +67,11 @@     _ -> needsParenForOp t  parTy :: LHsType GhcPs -> LHsType GhcPs+#if MIN_VERSION_ghc(9,10,0)+parTy = mkLocated . HsParTy (AnnParen AnnParens noSpanAnchor noSpanAnchor)+#else parTy = mkLocated . withEpAnnNotUsed HsParTy+#endif  sigWcType :: HsType' -> LHsSigWcType' sigWcType = noExt (withPlaceHolder Types.HsWC) . sigType@@ -72,7 +80,9 @@ wcType = noExt (withPlaceHolder Types.HsWC) . mkLocated  patSigType :: HsType' -> HsPatSigType'-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,10,0)+patSigType = mkHsPatSigType noAnn . mkLocated+#elif MIN_VERSION_ghc(9,2,0) patSigType = withEpAnnNotUsed mkHsPatSigType . mkLocated #elif MIN_VERSION_ghc(9,0,0) patSigType = mkHsPatSigType . builtLoc