Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions compat-8.10/GHC/Driver/Monad.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat-8.10/GHC/Driver/Session.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat-8.10/GHC/Hs/Type.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat-8.10/GHC/Plugins.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat-8.10/GHC/Tc/Types/Evidence.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat-8.10/GHC/Types/Basic.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat-8.10/GHC/Utils/Outputable.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Driver/Monad.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Driver/Session.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Binds.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Decls.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Expr.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Extension.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/ImpExp.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Lit.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Pat.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Type.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Hs/Utils.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Plugins.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Tc/Types/Evidence.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Types/Basic.hs

This file was deleted.

2 changes: 0 additions & 2 deletions compat/GHC/Utils/Outputable.hs

This file was deleted.

55 changes: 3 additions & 52 deletions ghc-show-ast/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,57 +62,16 @@ 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
[f] <- getArgs
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)
Expand Down Expand Up @@ -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
Expand Down
53 changes: 8 additions & 45 deletions ghc-source-gen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.*
Expand All @@ -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
Expand All @@ -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
48 changes: 2 additions & 46 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,15 @@ description: |
For more information, please see the <https://github.com/google/ghc-source-gen README>.

dependencies:
- base >= 4.7 && < 5
- ghc >= 8.4 && < 9.15
- base >= 4.15 && < 5
- ghc >= 9.0 && < 9.15

default-extensions:
- DataKinds
- FlexibleInstances
- 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
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 0 additions & 13 deletions src/GHC/SourceGen/Binds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
[]
Expand Down Expand Up @@ -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 <--

Expand Down
Loading