diff --git a/ChangeLog.md b/ChangeLog.md index 8860e0f..50ecb5c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ # 0.4.7.0 - Support GHC 9.12. - Support GHC 9.14. +- Remove support for GHC < 9.0. # 0.4.6.0 - Support GHC 9.10. diff --git a/compat-8.10/GHC/Driver/Monad.hs b/compat-8.10/GHC/Driver/Monad.hs deleted file mode 100644 index 400e560..0000000 --- a/compat-8.10/GHC/Driver/Monad.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Driver.Monad (module GhcMonad) where -import GhcMonad diff --git a/compat-8.10/GHC/Driver/Session.hs b/compat-8.10/GHC/Driver/Session.hs deleted file mode 100644 index 41916b7..0000000 --- a/compat-8.10/GHC/Driver/Session.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Driver.Session (module DynFlags) where -import DynFlags diff --git a/compat-8.10/GHC/Hs/Type.hs b/compat-8.10/GHC/Hs/Type.hs deleted file mode 100644 index ea69831..0000000 --- a/compat-8.10/GHC/Hs/Type.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Type (module GHC.Hs.Types) where -import GHC.Hs.Types \ No newline at end of file diff --git a/compat-8.10/GHC/Plugins.hs b/compat-8.10/GHC/Plugins.hs deleted file mode 100644 index 6f3444d..0000000 --- a/compat-8.10/GHC/Plugins.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Plugins (module GhcPlugins) where -import GhcPlugins \ No newline at end of file diff --git a/compat-8.10/GHC/Tc/Types/Evidence.hs b/compat-8.10/GHC/Tc/Types/Evidence.hs deleted file mode 100644 index e448c5c..0000000 --- a/compat-8.10/GHC/Tc/Types/Evidence.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Tc.Types.Evidence (module TcEvidence) where -import TcEvidence \ No newline at end of file diff --git a/compat-8.10/GHC/Types/Basic.hs b/compat-8.10/GHC/Types/Basic.hs deleted file mode 100644 index eec2bb6..0000000 --- a/compat-8.10/GHC/Types/Basic.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Types.Basic (module BasicTypes) where -import BasicTypes \ No newline at end of file diff --git a/compat-8.10/GHC/Utils/Outputable.hs b/compat-8.10/GHC/Utils/Outputable.hs deleted file mode 100644 index 69bc10b..0000000 --- a/compat-8.10/GHC/Utils/Outputable.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Utils.Outputable (module Outputable) where -import Outputable diff --git a/compat/GHC/Driver/Monad.hs b/compat/GHC/Driver/Monad.hs deleted file mode 100644 index 400e560..0000000 --- a/compat/GHC/Driver/Monad.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Driver.Monad (module GhcMonad) where -import GhcMonad diff --git a/compat/GHC/Driver/Session.hs b/compat/GHC/Driver/Session.hs deleted file mode 100644 index 41916b7..0000000 --- a/compat/GHC/Driver/Session.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Driver.Session (module DynFlags) where -import DynFlags diff --git a/compat/GHC/Hs.hs b/compat/GHC/Hs.hs deleted file mode 100644 index 9ec9e1c..0000000 --- a/compat/GHC/Hs.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs (module HsSyn) where -import HsSyn \ No newline at end of file diff --git a/compat/GHC/Hs/Binds.hs b/compat/GHC/Hs/Binds.hs deleted file mode 100644 index e52d6ae..0000000 --- a/compat/GHC/Hs/Binds.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Binds (module HsBinds) where -import HsBinds diff --git a/compat/GHC/Hs/Decls.hs b/compat/GHC/Hs/Decls.hs deleted file mode 100644 index c424527..0000000 --- a/compat/GHC/Hs/Decls.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Decls (module HsDecls) where -import HsDecls diff --git a/compat/GHC/Hs/Expr.hs b/compat/GHC/Hs/Expr.hs deleted file mode 100644 index 7bbd10c..0000000 --- a/compat/GHC/Hs/Expr.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Expr (module HsExpr) where -import HsExpr diff --git a/compat/GHC/Hs/Extension.hs b/compat/GHC/Hs/Extension.hs deleted file mode 100644 index 45dd589..0000000 --- a/compat/GHC/Hs/Extension.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Extension (module HsExtension) where -import HsExtension diff --git a/compat/GHC/Hs/ImpExp.hs b/compat/GHC/Hs/ImpExp.hs deleted file mode 100644 index bfd6ac2..0000000 --- a/compat/GHC/Hs/ImpExp.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.ImpExp (module HsImpExp) where -import HsImpExp diff --git a/compat/GHC/Hs/Lit.hs b/compat/GHC/Hs/Lit.hs deleted file mode 100644 index ea39661..0000000 --- a/compat/GHC/Hs/Lit.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Lit (module HsLit) where -import HsLit diff --git a/compat/GHC/Hs/Pat.hs b/compat/GHC/Hs/Pat.hs deleted file mode 100644 index a8983e7..0000000 --- a/compat/GHC/Hs/Pat.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Pat (module HsPat) where -import HsPat diff --git a/compat/GHC/Hs/Type.hs b/compat/GHC/Hs/Type.hs deleted file mode 100644 index 7828be4..0000000 --- a/compat/GHC/Hs/Type.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Type (module HsTypes) where -import HsTypes \ No newline at end of file diff --git a/compat/GHC/Hs/Utils.hs b/compat/GHC/Hs/Utils.hs deleted file mode 100644 index 9417f1b..0000000 --- a/compat/GHC/Hs/Utils.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Hs.Utils (module HsUtils) where -import HsUtils diff --git a/compat/GHC/Plugins.hs b/compat/GHC/Plugins.hs deleted file mode 100644 index 6f3444d..0000000 --- a/compat/GHC/Plugins.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Plugins (module GhcPlugins) where -import GhcPlugins \ No newline at end of file diff --git a/compat/GHC/Tc/Types/Evidence.hs b/compat/GHC/Tc/Types/Evidence.hs deleted file mode 100644 index e448c5c..0000000 --- a/compat/GHC/Tc/Types/Evidence.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Tc.Types.Evidence (module TcEvidence) where -import TcEvidence \ No newline at end of file diff --git a/compat/GHC/Types/Basic.hs b/compat/GHC/Types/Basic.hs deleted file mode 100644 index eec2bb6..0000000 --- a/compat/GHC/Types/Basic.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Types.Basic (module BasicTypes) where -import BasicTypes \ No newline at end of file diff --git a/compat/GHC/Utils/Outputable.hs b/compat/GHC/Utils/Outputable.hs deleted file mode 100644 index 69bc10b..0000000 --- a/compat/GHC/Utils/Outputable.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GHC.Utils.Outputable (module Outputable) where -import Outputable diff --git a/ghc-show-ast/Main.hs b/ghc-show-ast/Main.hs index 49a5dca..0e366e8 100644 --- a/ghc-show-ast/Main.hs +++ b/ghc-show-ast/Main.hs @@ -26,11 +26,10 @@ import qualified GHC.Types.Error as GHC (NoDiagnosticOpts(..)) #elif MIN_VERSION_ghc(9,2,0) import qualified GHC.Driver.Errors as Error import qualified GHC.Parser.Errors.Ppr as Error -#elif MIN_VERSION_ghc(9,0,0) +#else import qualified GHC.Utils.Error as Error #endif -#if MIN_VERSION_ghc(9,0,1) import GHC.Data.FastString import GHC.Types.Name ( Name @@ -63,49 +62,8 @@ import qualified GHC.Types.SrcLoc as GHC import qualified GHC.Data.StringBuffer as GHC import GHC.Paths (libdir) import GHC.Driver.Monad (liftIO) -#else -import FastString -import Name - ( Name - , isExternalName - , isInternalName - , isSystemName - , isWiredInName - , nameOccName - , nameUnique - ) -import OccName - ( OccName - , occNameSpace - , occNameString - , NameSpace - , varName - , dataName - , tvName - , tcClsName - ) - -import qualified DynFlags as GHC -import qualified FastString as GHC -import qualified GHC as GHC -import qualified GhcMonad as GHC -import qualified HeaderInfo as GHC -import qualified Lexer as GHC -import qualified Parser as Parser -import qualified SrcLoc as GHC -import qualified StringBuffer as GHC -import GHC.Paths (libdir) -#if MIN_VERSION_ghc(8,10,0) -import GhcMonad (liftIO) -import qualified ErrUtils as Error -#else -import qualified Outputable as GHC -#endif -#endif -#if MIN_VERSION_ghc(8,10,0) import System.Exit (exitFailure) -#endif main :: IO () main = do @@ -113,7 +71,7 @@ main = do result <- parseModule f print $ gPrint result -#if MIN_VERSION_ghc(9,0,1) && !MIN_VERSION_ghc(9,6,0) +#if !MIN_VERSION_ghc(9,6,0) parseModule :: FilePath -> IO GHC.HsModule #else parseModule :: FilePath -> IO (GHC.HsModule GHC.GhcPs) @@ -190,18 +148,11 @@ parseModule f = GHC.runGhc (Just libdir) $ do let errors = Error.pprError <$> GHC.getErrorMessages s Error.printBagOfErrors logger dflags errors exitFailure -#elif MIN_VERSION_ghc(8,10,0) +#else GHC.PFailed s -> liftIO $ do let (_warnings, errors) = GHC.messages s dflags Error.printBagOfErrors dflags errors exitFailure -#else - GHC.PFailed - -- Note: using printBagOfErrors on the messages doesn't produce any - -- useful output on older GHCs; so instead print the docs directly. - _messages - loc docs -> - error $ GHC.showPpr dflags loc ++ ": " ++ GHC.showSDoc dflags docs #endif gPrint :: Data a => a -> Doc diff --git a/ghc-source-gen.cabal b/ghc-source-gen.cabal index 7a177b6..51219c1 100644 --- a/ghc-source-gen.cabal +++ b/ghc-source-gen.cabal @@ -60,34 +60,9 @@ library FlexibleInstances TypeSynonymInstances build-depends: - base >=4.7 && <5 - , ghc >=8.4 && <9.15 + base >=4.15 && <5 + , ghc >=9.0 && <9.15 default-language: Haskell2010 - if impl(ghc<8.10) - other-modules: - GHC.Hs - GHC.Hs.Binds - GHC.Hs.Decls - GHC.Hs.Expr - GHC.Hs.Extension - GHC.Hs.ImpExp - GHC.Hs.Lit - GHC.Hs.Pat - GHC.Hs.Utils - hs-source-dirs: - compat - if impl(ghc<9.0) - other-modules: - GHC.Hs.Type - GHC.Driver.Monad - GHC.Driver.Session - GHC.Utils.Outputable - GHC.Types.Basic - GHC.Plugins - GHC.Tc.Types.Evidence - if impl(ghc>=8.10) && impl(ghc<9.0) - hs-source-dirs: - compat-8.10 test-suite name_test type: exitcode-stdio-1.0 @@ -103,8 +78,8 @@ test-suite name_test TypeSynonymInstances build-depends: QuickCheck >=2.10 && <2.17 - , base >=4.7 && <5 - , ghc >=8.4 && <9.15 + , base >=4.15 && <5 + , ghc >=9.0 && <9.15 , ghc-source-gen , tasty >=1.0 && <1.6 , tasty-hunit ==0.10.* @@ -124,18 +99,13 @@ test-suite pprint_examples FlexibleInstances TypeSynonymInstances build-depends: - base >=4.7 && <5 - , ghc >=8.4 && <9.15 + base >=4.15 && <5 + , ghc >=9.0 && <9.15 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.6 , tasty-hunit ==0.10.* default-language: Haskell2010 - if impl(ghc<9.0) - other-modules: - GHC.Utils.Outputable - hs-source-dirs: - compat test-suite pprint_test type: exitcode-stdio-1.0 @@ -150,17 +120,10 @@ test-suite pprint_test FlexibleInstances TypeSynonymInstances build-depends: - base >=4.7 && <5 - , ghc >=8.4 && <9.15 + base >=4.15 && <5 + , ghc >=9.0 && <9.15 , ghc-paths ==0.1.* , ghc-source-gen , tasty >=1.0 && <1.6 , tasty-hunit ==0.10.* default-language: Haskell2010 - if impl(ghc<9.0) - other-modules: - GHC.Driver.Monad - GHC.Driver.Session - GHC.Utils.Outputable - hs-source-dirs: - compat diff --git a/package.yaml b/package.yaml index c6770a1..94f5c29 100644 --- a/package.yaml +++ b/package.yaml @@ -29,8 +29,8 @@ description: | For more information, please see the . dependencies: -- base >= 4.7 && < 5 -- ghc >= 8.4 && < 9.15 +- base >= 4.15 && < 5 +- ghc >= 9.0 && < 9.15 default-extensions: - DataKinds @@ -38,36 +38,6 @@ default-extensions: - TypeSynonymInstances library: - when: - # GHC-8.10 introduced hierarchical modules. - # For compatibility, define wrapper modules for older GHC versions. - - condition: impl(ghc<8.10) - source-dirs: compat - other-modules: - - GHC.Hs - - GHC.Hs.Binds - - GHC.Hs.Decls - - GHC.Hs.Expr - - GHC.Hs.Extension - - GHC.Hs.ImpExp - - GHC.Hs.Lit - - GHC.Hs.Pat - - GHC.Hs.Utils - - verbatim: | - if impl(ghc<9.0) - other-modules: - GHC.Hs.Type - GHC.Driver.Monad - GHC.Driver.Session - GHC.Utils.Outputable - GHC.Types.Basic - GHC.Plugins - GHC.Tc.Types.Evidence - if impl(ghc>=8.10) && impl(ghc<9.0) - hs-source-dirs: - compat-8.10 - source-dirs: src other-modules: - GHC.SourceGen.Binds.Internal @@ -87,12 +57,6 @@ tests: - tasty >= 1.0 && < 1.6 - tasty-hunit == 0.10.* - when: - - condition: impl(ghc<9.0) - source-dirs: compat - other-modules: - - GHC.Utils.Outputable - # TODO: Fill out this test, and use it to replace pprint_examples. pprint_test: main: pprint_test.hs @@ -103,14 +67,6 @@ tests: - tasty >= 1.0 && < 1.6 - tasty-hunit == 0.10.* - when: - - condition: impl(ghc<9.0) - source-dirs: compat - other-modules: - - GHC.Driver.Monad - - GHC.Driver.Session - - GHC.Utils.Outputable - name_test: main: name_test.hs source-dirs: tests diff --git a/src/GHC/SourceGen/Binds.hs b/src/GHC/SourceGen/Binds.hs index 377c918..0bc9226 100644 --- a/src/GHC/SourceGen/Binds.hs +++ b/src/GHC/SourceGen/Binds.hs @@ -46,20 +46,13 @@ module GHC.SourceGen.Binds , (<--) ) where -#if MIN_VERSION_ghc(9,0,0) import GHC (LexicalFixity(..)) -#else -import GHC.Types.Basic (LexicalFixity(..)) -#endif import Data.Bool (bool) import Data.Maybe (fromMaybe) import GHC.Hs.Binds import GHC.Hs.Expr import GHC.Hs.Type import GHC.Plugins (isSymOcc) -#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) @@ -117,9 +110,6 @@ funBindsWithFixity :: HasValBind t => Maybe LexicalFixity -> OccNameStr -> [RawM funBindsWithFixity fixity name matches = bindB $ withPlaceHolder (noExt FunBind name' (matchGroup context matches) -#if !MIN_VERSION_ghc(9,0,1) - WpHole -#endif ) #if !MIN_VERSION_ghc(9,6,0) [] @@ -333,11 +323,8 @@ stmt e = (<--) :: Pat' -> HsExpr' -> Stmt' #if MIN_VERSION_ghc(9,10,0) 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 p <-- e = withPlaceHolder $ withEpAnnNotUsed BindStmt (builtPat p) (mkLocated e) - noSyntaxExpr noSyntaxExpr #endif infixl 1 <-- diff --git a/src/GHC/SourceGen/Binds/Internal.hs b/src/GHC/SourceGen/Binds/Internal.hs index 33ae9d8..ff0a84e 100644 --- a/src/GHC/SourceGen/Binds/Internal.hs +++ b/src/GHC/SourceGen/Binds/Internal.hs @@ -8,7 +8,6 @@ {-# LANGUAGE TypeApplications #-} module GHC.SourceGen.Binds.Internal where -#if MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic ( Origin(Generated) #if MIN_VERSION_ghc(9,10,0) , GenReason(OtherExpansion) @@ -19,10 +18,6 @@ import GHC.Types.Basic ( Origin(Generated) ) import GHC.Data.Bag (listToBag) import GHC.Hs.Extension (GhcPs) -#else -import BasicTypes (Origin(Generated)) -import Bag (listToBag) -#endif import GHC.Hs.Binds import GHC.Hs.Decls import GHC.Hs.Expr (MatchGroup(..), Match(..), GRHSs(..)) @@ -34,10 +29,6 @@ import qualified Data.List.NonEmpty as NonEmpty 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, emptyComments) #endif @@ -67,14 +58,9 @@ valBinds vbs = (listToBag $ map mkLocated binds) # endif (map mkLocated sigs) -#elif MIN_VERSION_ghc(8,6,0) - withEpAnnNotUsed HsValBinds - $ withNoAnnSortKey ValBinds - (listToBag $ map mkLocated binds) - (map mkLocated sigs) #else withEpAnnNotUsed HsValBinds - $ noExt ValBindsIn + $ withNoAnnSortKey ValBinds (listToBag $ map mkLocated binds) (map mkLocated sigs) #endif @@ -125,9 +111,7 @@ matchGroup context matches = noExt MG #endif matches' -#if !MIN_VERSION_ghc(8,6,0) - [] PlaceHolder -#elif !MIN_VERSION_ghc(9,6,0) +#if !MIN_VERSION_ghc(9,6,0) Generated #endif where diff --git a/src/GHC/SourceGen/Decl.hs b/src/GHC/SourceGen/Decl.hs index 5856cfc..a725fc7 100644 --- a/src/GHC/SourceGen/Decl.hs +++ b/src/GHC/SourceGen/Decl.hs @@ -29,9 +29,7 @@ module GHC.SourceGen.Decl , derivingStock , derivingAnyclass , derivingNewtype -#if MIN_VERSION_ghc(8,6,0) , derivingVia -#endif , standaloneDeriving , standaloneDerivingStock , standaloneDerivingNewtype @@ -51,7 +49,6 @@ module GHC.SourceGen.Decl , patSynBind ) where -#if MIN_VERSION_ghc(9,0,0) import GHC (LexicalFixity(Prefix)) import GHC.Data.Bag (listToBag) import GHC.Hs @@ -64,15 +61,6 @@ import GHC (GhcPs, LayoutInfo (NoLayoutInfo)) #else import GHC.Types.SrcLoc (LayoutInfo(NoLayoutInfo)) #endif - -#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 @@ -89,26 +77,19 @@ import GHC.Hs.Type , HsSrcBang(..) , HsType(..) , LHsType -#if MIN_VERSION_ghc(8,6,0) , HsWildCardBndrs (..) -#endif -#if MIN_VERSION_ghc(8,8,0) , HsArg(..) -#endif , SrcStrictness(..) , SrcUnpackedness(..) + , hsUnrestricted ) #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)) -#elif MIN_VERSION_ghc(8,6,0) -import GHC.Hs.Extension (NoExt(NoExt)) #else -import PlaceHolder (PlaceHolder(..)) +import GHC.Hs.Extension (NoExtField(NoExtField)) #endif import GHC.SourceGen.Binds.Internal @@ -190,14 +171,8 @@ class' context name vars decls , tcdCExt = (EpAnnNotUsed, NoAnnSortKey) #elif MIN_VERSION_ghc(9,2,0) , tcdCExt = (EpAnnNotUsed, NoAnnSortKey, NoLayoutInfo) -#elif MIN_VERSION_ghc(9,0,0) - , tcdCExt = NoLayoutInfo -#elif MIN_VERSION_ghc(8,10,0) - , tcdCExt = NoExtField -#elif MIN_VERSION_ghc(8,6,0) - , tcdCExt = NoExt #else - , tcdFVs = PlaceHolder + , tcdCExt = NoLayoutInfo #endif , tcdLName = typeRdrName $ unqual name , tcdTyVars = mkQTyVars vars @@ -264,10 +239,8 @@ instance' ty decls = noExt InstD $ noExt ClsInstD $ ClsInstDecl , cid_ext = (Nothing, noAnn, NoAnnSortKey) #elif MIN_VERSION_ghc(9,2,0) , cid_ext = (EpAnnNotUsed, NoAnnSortKey) -#elif MIN_VERSION_ghc(8,10,0) +#else , cid_ext = NoExtField -#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] @@ -324,19 +297,6 @@ tyFamInst name params ty = tyFamInstD tyFamInstDecl = withEpAnnNotUsed TyFamInstDecl famEqn tycon bndrs pats = withEpAnnNotUsed FamEqn tycon bndrs (map HsValArg pats) eqn_bndrs = noExt HsOuterImplicit -#elif MIN_VERSION_ghc(8,8,0) -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 @@ -348,7 +308,7 @@ tyFamInst name params ty = tyFamInstD (mkLocated ty) where tyFamInstDecl = TyFamInstDecl . withPlaceHolder . noExt (withPlaceHolder HsIB) - famEqn tycon _ = noExt FamEqn tycon + famEqn tycon bndrs pats = noExt FamEqn tycon bndrs (map HsValArg pats) eqn_bndrs = Nothing #endif @@ -571,11 +531,6 @@ strict f = f { strictness = SrcStrict } lazy :: Field -> Field lazy f = f { strictness = SrcLazy } -#if !MIN_VERSION_ghc(9,0,0) -hsUnrestricted :: a -> a -hsUnrestricted = id -#endif - #if MIN_VERSION_ghc(9,14,0) renderField :: Field -> HsConDeclField GhcPs #else @@ -605,10 +560,8 @@ renderCon98Decl name details = conDeclH98 = ConDeclH98 noAnn #elif MIN_VERSION_ghc(9,2,0) conDeclH98 = withEpAnnNotUsed ConDeclH98 -#elif MIN_VERSION_ghc(8,6,0) - conDeclH98 n = noExt ConDeclH98 n . builtLoc #else - conDeclH98 n _ _ = ConDeclH98 n Nothing + conDeclH98 n = noExt ConDeclH98 n . builtLoc #endif deriving' :: [HsType'] -> HsDerivingClause' @@ -664,7 +617,6 @@ derivingAnyclass = derivingWay (Just strat) strat = AnyclassStrategy #endif -#if MIN_VERSION_ghc(8,6,0) -- | A `DerivingVia` clause. -- -- > deriving (Eq, Show) via T @@ -681,7 +633,6 @@ derivingVia t = derivingWay (Just $ strat $ sigType t) #else strat = ViaStrategy #endif -#endif standaloneDeriving :: HsType' -> HsDecl' standaloneDeriving = standaloneDerivingWay Nothing @@ -729,12 +680,7 @@ standaloneDerivingWay way ty = noExt DerivD derivDecl #else withEpAnnNotUsed DerivDecl (hsWC $ sigType ty) (fmap builtLoc way) Nothing #endif - hsWC = -#if MIN_VERSION_ghc(8,6,0) - noExt HsWC -#else - id -#endif + hsWC = noExt HsWC -- | Declares multiple pattern signatures of the same type. -- diff --git a/src/GHC/SourceGen/Expr.hs b/src/GHC/SourceGen/Expr.hs index 3a0a0cd..c3b5336 100644 --- a/src/GHC/SourceGen/Expr.hs +++ b/src/GHC/SourceGen/Expr.hs @@ -52,11 +52,7 @@ import GHC.Hs.Type ( ) import GHC.Hs.Utils (mkHsIf) import Data.String (fromString) -#if MIN_VERSION_ghc(9,0,0) import GHC.Types.SrcLoc (unLoc, GenLocated(..)) -#else -import SrcLoc (unLoc, GenLocated(..)) -#endif #if MIN_VERSION_ghc(9,2,0) import GHC.Parser.Annotation (EpAnn(..)) @@ -191,10 +187,8 @@ do' :: [Stmt'] -> HsExpr' do' = withPlaceHolder #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 + . withEpAnnNotUsed HsDo (DoExpr Nothing) #endif . mkLocated . map (mkLocated . parenthesizeIfLet) where @@ -202,13 +196,8 @@ do' = withPlaceHolder -- do let x = ... -- in x -- which is not valid Haskell. -#if MIN_VERSION_ghc(8,6,0) parenthesizeIfLet (BodyStmt ext e@(L _ HsLet{}) x y) = BodyStmt ext (parExpr e) x y -#else - parenthesizeIfLet (BodyStmt e@(L _ HsLet{}) x y tc) - = BodyStmt (parExpr e) x y tc -#endif parenthesizeIfLet s = s -- | A list comprehension expression. @@ -222,11 +211,7 @@ do' = withPlaceHolder listComp :: HsExpr' -> [Stmt'] -> HsExpr' listComp lastExpr stmts = let lastStmt = noExt LastStmt (mkLocated lastExpr) ret noSyntaxExpr -#if MIN_VERSION_ghc(9,0,0) ret = Nothing -#else - ret = False -#endif #if MIN_VERSION_ghc(9,10,0) in withPlaceHolder . HsDo noAnn ListComp . mkLocated . map mkLocated $ stmts ++ [lastStmt] @@ -243,12 +228,8 @@ listComp lastExpr stmts = (@::@) :: HsExpr' -> HsType' -> HsExpr' #if MIN_VERSION_ghc(9,10,0) 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) -e @::@ t = ExprWithTySig (sigWcType t) (builtLoc e) #else -e @::@ t = ExprWithTySig (builtLoc e) (sigWcType t) +e @::@ t = withEpAnnNotUsed ExprWithTySig (mkLocated e) (sigWcType t) #endif -- TODO: The Outputable instance prepends extra spaces; I'm not sure why. @@ -264,12 +245,8 @@ tyApp e t = HsAppType (EpTok noSpanAnchor) e' t' tyApp e t = noExt HsAppType e' noHsTok t' #elif MIN_VERSION_ghc(9,2,0) tyApp e t = HsAppType builtSpan e' t' -#elif MIN_VERSION_ghc(8,8,0) -tyApp e t = noExt HsAppType e' t' -#elif MIN_VERSION_ghc(8,6,0) -tyApp e t = HsAppType t' e' #else -tyApp e t = HsAppType e' t' +tyApp e t = noExt HsAppType e' t' #endif where t' = wcType $ unLoc $ parenthesizeTypeForApp $ mkLocated t @@ -286,9 +263,6 @@ 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 #if MIN_VERSION_ghc(9,12,0) $ noExt HsRecFields #else @@ -395,10 +369,8 @@ arithSeq :: ArithSeqInfo GhcPs -> HsExpr' arithSeq = #if MIN_VERSION_ghc(9,10,0) ArithSeq noAnn Nothing -#elif MIN_VERSION_ghc(8,6,0) - withEpAnnNotUsed ArithSeq Nothing #else - ArithSeq noPostTcExpr Nothing + withEpAnnNotUsed ArithSeq Nothing #endif -- | An arithmetic sequence expression with a start value. diff --git a/src/GHC/SourceGen/Expr/Internal.hs b/src/GHC/SourceGen/Expr/Internal.hs index 1cb3488..d6496e8 100644 --- a/src/GHC/SourceGen/Expr/Internal.hs +++ b/src/GHC/SourceGen/Expr/Internal.hs @@ -8,11 +8,7 @@ module GHC.SourceGen.Expr.Internal where import GHC.Hs.Expr -#if MIN_VERSION_ghc(9,0,0) import GHC.Types.SrcLoc (unLoc) -#else -import SrcLoc (unLoc) -#endif import GHC.SourceGen.Lit.Internal import GHC.SourceGen.Syntax.Internal @@ -43,17 +39,11 @@ parExpr e = mkLocated $ withEpAnnNotUsed HsPar mkToken e mkToken parExpr = mkLocated . withEpAnnNotUsed HsPar #endif -#if MIN_VERSION_ghc(8,6,0) -#define WILD_EXT _ -#else -#define WILD_EXT -#endif - needsExprForApp, needsExprForOp :: HsExpr' -> Bool needsExprForOp e = case e of -- TODO: more care for literals; only needed for negative numbers? - HsLit WILD_EXT l -> litNeedsParen l - HsOverLit WILD_EXT l -> overLitNeedsParen l + HsLit _ l -> litNeedsParen l + HsOverLit _ l -> overLitNeedsParen l HsLam{} -> True #if !MIN_VERSION_ghc(9,10,0) HsLamCase{} -> True diff --git a/src/GHC/SourceGen/Lit.hs b/src/GHC/SourceGen/Lit.hs index 6ddb617..2a90ef8 100644 --- a/src/GHC/SourceGen/Lit.hs +++ b/src/GHC/SourceGen/Lit.hs @@ -21,12 +21,9 @@ module GHC.SourceGen.Lit import GHC.Types.SourceText (mkTHFractionalLit, mkIntegralLit) import GHC.Data.FastString (fsLit) import GHC.Parser.Annotation (noAnn) -#elif MIN_VERSION_ghc(9,0,0) +#else import GHC.Types.Basic (mkFractionalLit, mkIntegralLit) import GHC.Data.FastString (fsLit) -#else -import BasicTypes (mkFractionalLit, mkIntegralLit) -import FastString (fsLit) #endif import GHC.Hs.Lit import GHC.Hs.Expr (noExpr, noSyntaxExpr, HsExpr(..)) diff --git a/src/GHC/SourceGen/Lit/Internal.hs b/src/GHC/SourceGen/Lit/Internal.hs index e88f8a0..456a118 100644 --- a/src/GHC/SourceGen/Lit/Internal.hs +++ b/src/GHC/SourceGen/Lit/Internal.hs @@ -9,10 +9,8 @@ module GHC.SourceGen.Lit.Internal where #if MIN_VERSION_ghc(9,2,0) import GHC.Types.SourceText (SourceText(NoSourceText), FractionalLit(..), IntegralLit(..)) -#elif MIN_VERSION_ghc(9,0,0) -import GHC.Types.Basic (SourceText(NoSourceText), FractionalLit(..), IntegralLit(..)) #else -import BasicTypes (SourceText(NoSourceText), FractionalLit(..), IntegralLit(..)) +import GHC.Types.Basic (SourceText(NoSourceText), FractionalLit(..), IntegralLit(..)) #endif import GHC.Hs.Lit import GHC.SourceGen.Syntax.Internal diff --git a/src/GHC/SourceGen/Module.hs b/src/GHC/SourceGen/Module.hs index 4a062ab..f2026b7 100644 --- a/src/GHC/SourceGen/Module.hs +++ b/src/GHC/SourceGen/Module.hs @@ -36,9 +36,7 @@ import GHC.Hs ( HsModule(..) , ImportDecl(..) , simpleImportDecl -#if MIN_VERSION_ghc(8,10,0) , ImportDeclQualifiedStyle(..) -#endif #if MIN_VERSION_ghc(9,2,0) , EpAnn(..) #endif @@ -51,15 +49,11 @@ import GHC.Hs , LIEWrappedName #endif ) -#if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) +#if !MIN_VERSION_ghc(9,6,0) import GHC.Types.SrcLoc (LayoutInfo(..)) #endif -#if MIN_VERSION_ghc(9,0,0) import GHC.Unit.Module (IsBootInterface(..)) import GHC.Types.Name.Reader (RdrName) -#else -import RdrName (RdrName) -#endif #if MIN_VERSION_ghc(9,4,0) import GHC.Types.PkgQual (RawPkgQual(..)) #endif @@ -101,9 +95,7 @@ module' name exports imports decls = HsModule #else , hsmodDeprecMessage = Nothing , hsmodHaddockModHeader = Nothing -# if MIN_VERSION_ghc(9,0,0) , hsmodLayout = NoLayoutInfo -# endif # if MIN_VERSION_ghc(9,2,0) , hsmodAnn = EpAnnNotUsed # endif @@ -112,11 +104,7 @@ module' name exports imports decls = HsModule qualified' :: ImportDecl' -> ImportDecl' qualified' d = d { ideclQualified = -#if MIN_VERSION_ghc(8,10,0) QualifiedPre -#else - True -#endif } as' :: ImportDecl' -> ModuleNameStr -> ImportDecl' @@ -143,13 +131,7 @@ hiding d ies = d -- | Adds the @{-# SOURCE #-}@ pragma to an import. source :: ImportDecl' -> ImportDecl' -source d = d { ideclSource = -#if MIN_VERSION_ghc(9,0,0) - IsBoot -#else - True -#endif -} +source d = d { ideclSource = IsBoot } -- | Exports all methods and/or constructors. -- @@ -213,10 +195,7 @@ withEpAnnNotUsed' = ($ (Nothing, EpAnnNotUsed)) #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 +withEpAnnNotUsed' :: (NoExtField -> a) -> a withEpAnnNotUsed' = withEpAnnNotUsed #endif diff --git a/src/GHC/SourceGen/Name.hs b/src/GHC/SourceGen/Name.hs index 3fa6056..cf7d7cc 100644 --- a/src/GHC/SourceGen/Name.hs +++ b/src/GHC/SourceGen/Name.hs @@ -28,17 +28,10 @@ module GHC.SourceGen.Name , moduleNameStrToString ) where -#if MIN_VERSION_ghc(9,0,0) import GHC.Data.FastString (unpackFS) import GHC.Unit.Module (moduleNameString) import GHC.Types.Name.Occurrence (OccName, occNameFS, occNameSpace, isVarNameSpace) import GHC.Types.Name (Name, nameOccName) -#else -import FastString (unpackFS) -import Module (moduleNameString) -import OccName (OccName, occNameFS, occNameSpace, isVarNameSpace) -import Name (Name, nameOccName) -#endif import GHC.SourceGen.Name.Internal unqual :: OccNameStr -> RdrNameStr diff --git a/src/GHC/SourceGen/Name/Internal.hs b/src/GHC/SourceGen/Name/Internal.hs index d310415..e2e6199 100644 --- a/src/GHC/SourceGen/Name/Internal.hs +++ b/src/GHC/SourceGen/Name/Internal.hs @@ -11,17 +11,10 @@ import Data.Char (isAlphaNum, isUpper) import Data.Function (on) import Data.List (intercalate) import Data.String (IsString(..)) -#if MIN_VERSION_ghc(9,0,0) import GHC.Data.FastString (FastString, fsLit) import GHC.Unit.Module (mkModuleNameFS, ModuleName, moduleNameString) import GHC.Types.Name.Occurrence import GHC.Types.Name.Reader -#else -import FastString (FastString, fsLit) -import Module (mkModuleNameFS, ModuleName, moduleNameString) -import OccName -import RdrName -#endif #if MIN_VERSION_ghc(9,2,0) import GHC.Data.FastString (LexicalFastString(..)) @@ -29,10 +22,8 @@ import GHC.Data.FastString (LexicalFastString(..)) #if MIN_VERSION_ghc(9,2,0) import GHC.Parser.Annotation (LocatedN) -#elif MIN_VERSION_ghc(9,0,0) -import GHC.Types.SrcLoc (Located) #else -import SrcLoc (Located) +import GHC.Types.SrcLoc (Located) #endif import GHC.SourceGen.Syntax.Internal (mkLocated) diff --git a/src/GHC/SourceGen/Overloaded.hs b/src/GHC/SourceGen/Overloaded.hs index c31780c..6e6f8f0 100644 --- a/src/GHC/SourceGen/Overloaded.hs +++ b/src/GHC/SourceGen/Overloaded.hs @@ -30,10 +30,11 @@ import GHC.Hs.Type , mkHsOpTy #endif ) -import GHC.Hs (IE(..), IEWrappedName(..)) -#if !MIN_VERSION_ghc(8,6,0) -import PlaceHolder(PlaceHolder(..)) +import GHC.Hs (IE(..), IEWrappedName(..) +#if MIN_VERSION_ghc(9,6,0) + , noExtField #endif + ) import GHC.Hs ( HsExpr(..) @@ -48,18 +49,11 @@ import GHC.Hs #if MIN_VERSION_ghc(9,10,0) import GHC.Parser.Annotation (AnnList (..), noAnn) #endif -#if MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic (Boxity(..)) import GHC.Core.DataCon (dataConName) import GHC.Types.Name.Reader (nameRdrName) import GHC.Builtin.Types (consDataCon_RDR, nilDataCon, unitDataCon) import GHC.Types.Var (Specificity(..)) -#else -import BasicTypes (Boxity(..)) -import DataCon (dataConName) -import RdrName (nameRdrName) -import TysWiredIn (consDataCon_RDR, nilDataCon, unitDataCon) -#endif import GHC.SourceGen.Expr.Internal import GHC.SourceGen.Name.Internal @@ -176,9 +170,6 @@ instance App HsExpr' where = withEpAnnNotUsed OpApp (parenthesizeExprForOp $ mkLocated x) (mkLocated $ var o) -#if !MIN_VERSION_ghc(8,6,0) - PlaceHolder -#endif (parenthesizeExprForOp $ mkLocated y) #endif #if MIN_VERSION_ghc(9,10,0) @@ -256,10 +247,8 @@ instance HasTuple Pat' where tupleOf b ps = #if MIN_VERSION_ghc(9,10,0) TuplePat noAnn (map builtPat ps) b -#elif MIN_VERSION_ghc(8,6,0) - withEpAnnNotUsed TuplePat (map builtPat ps) b #else - withEpAnnNotUsed TuplePat (map builtPat ps) b [] + withEpAnnNotUsed TuplePat (map builtPat ps) b #endif unit = noExt VarPat unitDataConName @@ -300,10 +289,8 @@ instance HasList HsExpr' where instance HasList Pat' where #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 + list = withEpAnnNotUsed ListPat . map builtPat #endif nil = noExt VarPat nilDataConName cons = noExt VarPat $ mkLocated $ consDataCon_RDR @@ -358,14 +345,11 @@ instance BVar HsTyVarBndr' where bvar = withEpAnnNotUsed UserTyVar HsBndrRequired . typeRdrName . UnqualStr instance BVar HsTyVarBndrS' where bvar = withEpAnnNotUsed UserTyVar SpecifiedSpec . typeRdrName . UnqualStr -#elif MIN_VERSION_ghc(9,0,0) +#else 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 #endif instance Var IE' where diff --git a/src/GHC/SourceGen/Pat.hs b/src/GHC/SourceGen/Pat.hs index 2b3eddc..964b0d8 100644 --- a/src/GHC/SourceGen/Pat.hs +++ b/src/GHC/SourceGen/Pat.hs @@ -68,10 +68,8 @@ conP c pats = conPat (valueRdrName c) (prefixCon (map (builtPat . parenthesize) where #if MIN_VERSION_ghc(9,10,0) conPat = ConPat noAnn -#elif MIN_VERSION_ghc(9,0,0) - conPat = withEpAnnNotUsed ConPat #else - conPat = ConPatIn + conPat = withEpAnnNotUsed ConPat #endif #if !MIN_VERSION_ghc(9,14,0) && MIN_VERSION_ghc(9,2,0) prefixCon = PrefixCon [] @@ -91,10 +89,8 @@ recordConP :: RdrNameStr -> [(RdrNameStr, Pat')] -> Pat' recordConP c fs = #if MIN_VERSION_ghc(9,10,0) ConPat noAnn -#elif MIN_VERSION_ghc(9,0,0) - withEpAnnNotUsed ConPat #else - ConPatIn + withEpAnnNotUsed ConPat #endif (valueRdrName c) #if MIN_VERSION_ghc(9,12,0) @@ -161,10 +157,6 @@ lazyP = withEpAnnNotUsed LazyPat . builtPat . parenthesize sigP :: Pat' -> HsType' -> Pat' #if MIN_VERSION_ghc(9,10,0) 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) -sigP p t = SigPat (patSigType t) (builtPat p) #else -sigP p t = SigPatIn (builtPat p) (patSigType t) +sigP p t = withEpAnnNotUsed SigPat (builtPat p) (patSigType t) #endif diff --git a/src/GHC/SourceGen/Pat/Internal.hs b/src/GHC/SourceGen/Pat/Internal.hs index 37a18e8..b889af2 100644 --- a/src/GHC/SourceGen/Pat/Internal.hs +++ b/src/GHC/SourceGen/Pat/Internal.hs @@ -5,13 +5,8 @@ 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) -#else -import GHC.Hs.Type (HsConDetails(..)) -import SrcLoc (unLoc) -#endif import GHC.SourceGen.Lit.Internal (litNeedsParen, overLitNeedsParen) import GHC.SourceGen.Syntax.Internal @@ -25,34 +20,17 @@ parenthesize p needsPar :: Pat' -> Bool -#if MIN_VERSION_ghc(8,6,0) needsPar (LitPat _ l) = litNeedsParen l needsPar (NPat _ l _ _) = overLitNeedsParen $ unLoc l -#else -needsPar (LitPat l) = litNeedsParen l -needsPar (NPat l _ _ _) = overLitNeedsParen $ unLoc l -#endif #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 #else -needsPar (ConPatIn _ (PrefixCon xs)) = not $ null xs +needsPar (ConPat _ _ (PrefixCon xs)) = not $ null xs #endif -#if MIN_VERSION_ghc(9,0,0) needsPar (ConPat _ _ (InfixCon _ _)) = True -#else -needsPar (ConPatIn _ (InfixCon _ _)) = True -needsPar ConPatOut{} = True -#endif -#if MIN_VERSION_ghc(8,6,0) needsPar SigPat{} = True -#else -needsPar SigPatIn{} = True -needsPar SigPatOut{} = True -#endif needsPar _ = False parPat :: Pat' -> Pat' diff --git a/src/GHC/SourceGen/Pretty.hs b/src/GHC/SourceGen/Pretty.hs index 4e17e00..d48ba5a 100644 --- a/src/GHC/SourceGen/Pretty.hs +++ b/src/GHC/SourceGen/Pretty.hs @@ -25,10 +25,7 @@ hPutPpr :: Outputable a => Handle -> a -> Ghc () hPutPpr h x = do dflags <- getDynFlags liftIO $ printForUser dflags h neverQualify -#if MIN_VERSION_ghc(9,0,1) - AllTheWay -#endif - $ ppr x + AllTheWay $ ppr x putPpr :: Outputable a => a -> Ghc () putPpr = hPutPpr stdout diff --git a/src/GHC/SourceGen/Syntax/Internal.hs b/src/GHC/SourceGen/Syntax/Internal.hs index b8f16d9..6e17d31 100644 --- a/src/GHC/SourceGen/Syntax/Internal.hs +++ b/src/GHC/SourceGen/Syntax/Internal.hs @@ -34,13 +34,7 @@ import GHC.Hs , LHsSigWcType , LHsWcType , TyFamInstDecl -#if !MIN_VERSION_ghc(8,8,0) - , LHsRecField - , LHsRecUpdField -#endif -#if MIN_VERSION_ghc(9,0,0) , HsPatSigType -#endif #if MIN_VERSION_ghc(9,2,0) , HsConDeclH98Details #else @@ -48,22 +42,13 @@ import GHC.Hs #endif ) import GHC.Hs.Binds (Sig, HsLocalBinds) -#if MIN_VERSION_ghc(8,6,0) import GHC.Hs.Decls (DerivStrategy) -#else -import BasicTypes (DerivStrategy) -#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 -import RdrName (RdrName) -import SrcLoc (SrcSpan, Located, GenLocated(..), mkGeneralSrcSpan) -#endif #if MIN_VERSION_ghc(9,2,0) && !MIN_VERSION_ghc(9,6,0) import GHC.Parser.Annotation @@ -75,30 +60,15 @@ import GHC.Parser.Annotation ) #endif -#if MIN_VERSION_ghc(9,0,0) import GHC.Types.Basic (PromotionFlag(..)) -#elif MIN_VERSION_ghc(8,8,0) -import BasicTypes (PromotionFlag(..)) -#else -import GHC.Hs.Type (Promoted(..)) -#endif #if MIN_VERSION_ghc(9,8,0) import GHC.Hs.Type (HsBndrVis) #endif -#if MIN_VERSION_ghc(8,10,0) import qualified GHC.Hs as GHC -#elif MIN_VERSION_ghc(8,6,0) -import qualified GHC.Hs.Extension as GHC -#else -import qualified HsExtension as GHC -import qualified PlaceHolder as GHC -#endif -#if MIN_VERSION_ghc(9,0,0) import GHC.Types.Var (Specificity) -#endif #if MIN_VERSION_ghc(9,4,0) import GHC.Parser.Annotation @@ -106,30 +76,13 @@ import GHC.Parser.Annotation import GHC.Hs.Extension (GhcPs) -#if MIN_VERSION_ghc(8,10,0) type NoExtField = GHC.NoExtField -#elif MIN_VERSION_ghc(8,6,0) -type NoExtField = GHC.NoExt -#endif -#if MIN_VERSION_ghc(8,10,0) noExt :: (NoExtField -> a) -> a noExt = ($ GHC.NoExtField) -#elif MIN_VERSION_ghc(8,6,0) -noExt :: (NoExtField -> a) -> a -noExt = ($ GHC.NoExt) -#else -noExt :: a -> a -noExt = id -#endif -#if MIN_VERSION_ghc(8,6,0) noExtOrPlaceHolder :: (NoExtField -> a) -> a noExtOrPlaceHolder = noExt -#else -noExtOrPlaceHolder :: (GHC.PlaceHolder -> a) -> a -noExtOrPlaceHolder = withPlaceHolder -#endif #if MIN_VERSION_ghc(9,10,0) withEpAnnNotUsed :: a -> a @@ -137,12 +90,9 @@ withEpAnnNotUsed = id #elif MIN_VERSION_ghc(9,2,0) withEpAnnNotUsed :: (EpAnn ann -> a) -> a withEpAnnNotUsed = ($ EpAnnNotUsed) -#elif MIN_VERSION_ghc(8,6,0) +#else withEpAnnNotUsed :: (NoExtField -> a) -> a withEpAnnNotUsed = noExt -#else -withEpAnnNotUsed :: a -> a -withEpAnnNotUsed = id #endif #if MIN_VERSION_ghc(9,10,0) @@ -151,40 +101,24 @@ withNoAnnSortKey = ($ NoAnnSortKey) #elif MIN_VERSION_ghc(9,2,0) withNoAnnSortKey :: (AnnSortKey -> a) -> a withNoAnnSortKey = ($ NoAnnSortKey) -#elif MIN_VERSION_ghc(8,6,0) +#else withNoAnnSortKey :: (NoExtField -> a) -> a withNoAnnSortKey = noExt -#else -withNoAnnSortKey :: a -> a -withNoAnnSortKey = id #endif #if MIN_VERSION_ghc(9,2,0) withEmptyEpAnnComments :: (EpAnnComments -> a) -> a withEmptyEpAnnComments = ($ emptyComments) -#elif MIN_VERSION_ghc(8,6,0) +#else withEmptyEpAnnComments :: (NoExtField -> a) -> a withEmptyEpAnnComments = noExt -#else -withEmptyEpAnnComments :: a -> a -withEmptyEpAnnComments = id #endif -#if MIN_VERSION_ghc(8,6,0) withPlaceHolder :: a -> a withPlaceHolder = id -#else -withPlaceHolder :: (GHC.PlaceHolder -> a) -> a -withPlaceHolder = ($ GHC.PlaceHolder) -#endif -#if MIN_VERSION_ghc(8,6,0) withPlaceHolders :: a -> a withPlaceHolders = id -#else -withPlaceHolders :: ([GHC.PlaceHolder] -> a) -> a -withPlaceHolders = ($ []) -#endif builtSpan :: SrcSpan builtSpan = mkGeneralSrcSpan "" @@ -200,7 +134,6 @@ type SrcSpanAnn ann = GHC.SrcSpanAnn' (EpAnn ann) 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) @@ -212,26 +145,16 @@ 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 --- stored in each node, and LPat is a synonym for Pat. builtPat :: Pat' -> LPat' #if MIN_VERSION_ghc(9,2,0) builtPat = mkLocated -#elif MIN_VERSION_ghc(8,8,0) && !MIN_VERSION_ghc(8,10,0) -builtPat = id #else builtPat = builtLoc #endif -#if MIN_VERSION_ghc(8,8,0) promoted, notPromoted :: PromotionFlag promoted = IsPromoted notPromoted = NotPromoted -#else -promoted, notPromoted :: Promoted -promoted = Promoted -notPromoted = NotPromoted -#endif -- TODO: these Haddock cross-references don't link to the actual -- definition, only to the module they come from. I think it's @@ -302,16 +225,13 @@ type IE' = IE GhcPs #if MIN_VERSION_ghc(9,8,0) type HsTyVarBndr' = HsTyVarBndr (HsBndrVis GhcPs) GhcPs type HsTyVarBndrS' = HsTyVarBndr Specificity GhcPs -#elif MIN_VERSION_ghc(9,0,0) +#else type HsTyVarBndr' = HsTyVarBndr () GhcPs type HsTyVarBndrS' = HsTyVarBndr Specificity GhcPs -#else -type HsTyVarBndr' = HsTyVarBndr GhcPs -type HsTyVarBndrS' = HsTyVarBndr GhcPs #endif type HsLit' = HsLit GhcPs -#if MIN_VERSION_ghc(9,0,0) && !MIN_VERSION_ghc(9,6,0) +#if !MIN_VERSION_ghc(9,6,0) type HsModule' = HsModule #else type HsModule' = HsModule GhcPs @@ -322,10 +242,8 @@ type HsValBinds' = HsValBinds GhcPs type Sig' = Sig GhcPs #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 +type HsMatchContext' = HsMatchContext GhcPs #endif type Match' = Match GhcPs type MatchGroup' = MatchGroup GhcPs @@ -354,17 +272,9 @@ type LHsRecUpdField' = LHsRecUpdField GhcPs type LPat' = LPat GhcPs type TyFamInstDecl' = TyFamInstDecl GhcPs -#if MIN_VERSION_ghc(8,6,0) type DerivStrategy' = DerivStrategy GhcPs -#else -type DerivStrategy' = DerivStrategy -#endif -#if MIN_VERSION_ghc(9,0,0) type HsPatSigType' = HsPatSigType GhcPs -#else -type HsPatSigType' = LHsSigWcType' -#endif #if MIN_VERSION_ghc(9,2,0) type LIdP = GHC.LIdP GHC.GhcPs diff --git a/src/GHC/SourceGen/Type.hs b/src/GHC/SourceGen/Type.hs index b90bdd3..17be2cf 100644 --- a/src/GHC/SourceGen/Type.hs +++ b/src/GHC/SourceGen/Type.hs @@ -22,12 +22,8 @@ module GHC.SourceGen.Type ) where import Data.String (fromString) -#if MIN_VERSION_ghc(9,0,0) import GHC.Hs.Type import GHC.Parser.Annotation -#else -import GHC.Hs.Type -#endif #if MIN_VERSION_ghc(9,4,0) import Language.Haskell.Syntax.Extension @@ -96,11 +92,9 @@ a --> b = #elif MIN_VERSION_ghc(9,4,0) withEpAnnNotUsed HsFunTy (HsUnrestrictedArrow mkUniToken) -#elif MIN_VERSION_ghc(9,0,0) - withEpAnnNotUsed HsFunTy - (HsUnrestrictedArrow NormalSyntax) #else withEpAnnNotUsed HsFunTy + (HsUnrestrictedArrow NormalSyntax) #endif (parenthesizeTypeForFun $ mkLocated a) (mkLocated b) @@ -124,19 +118,10 @@ forall' ts t = forall' ts = noExt hsForAllTy (map mkLocated ts) . mkLocated where 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 + hsForAllTy x = HsForAllTy x . mkHsForAllInvisTele #endif -- | Qualify a type with constraints. @@ -175,11 +160,8 @@ kindedVar v t = withEpAnnNotUsed KindedTyVar HsBndrRequired (typeRdrName $ UnqualStr v) (mkLocated t) -#elif MIN_VERSION_ghc(9,0,0) - withEpAnnNotUsed KindedTyVar - () - (typeRdrName $ UnqualStr v) (mkLocated t) #else withEpAnnNotUsed KindedTyVar + () (typeRdrName $ UnqualStr v) (mkLocated t) #endif diff --git a/src/GHC/SourceGen/Type/Internal.hs b/src/GHC/SourceGen/Type/Internal.hs index 3f53537..f869cc2 100644 --- a/src/GHC/SourceGen/Type/Internal.hs +++ b/src/GHC/SourceGen/Type/Internal.hs @@ -9,13 +9,8 @@ module GHC.SourceGen.Type.Internal where import GHC.Hs (GhcPs) -#if MIN_VERSION_ghc(9,0,0) import GHC.Hs.Type as Types import GHC.Types.SrcLoc (unLoc) -#else -import GHC.Hs.Type as Types -import SrcLoc (unLoc) -#endif #if MIN_VERSION_ghc(9,10,0) import GHC.Parser.Annotation (AnnParen, noAnn, noSpanAnchor) @@ -84,8 +79,6 @@ patSigType :: HsType' -> HsPatSigType' 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 #else -patSigType = sigWcType +patSigType = mkHsPatSigType . builtLoc #endif diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 4efc954..0000000 --- a/stack.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2019 Google LLC -# -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file or at -# https://developers.google.com/open-source/licenses/bsd - -resolver: lts-18.28 -packages: -- . -- ghc-show-ast - -ghc-options: - "$locals": -Wall -Werror diff --git a/tests/name_test.hs b/tests/name_test.hs index c7436ae..88bf93c 100644 --- a/tests/name_test.hs +++ b/tests/name_test.hs @@ -4,11 +4,7 @@ module Main (main) where import GHC.SourceGen.Name -#if MIN_VERSION_ghc(9,0,1) import GHC.Types.Name.Occurrence -#else -import OccName -#endif import Data.List (intercalate) import Data.String (fromString)