diff --git a/hie-compat/hie-compat.cabal b/hie-compat/hie-compat.cabal index 9778485028..7ceccc51ab 100644 --- a/hie-compat/hie-compat.cabal +++ b/hie-compat/hie-compat.cabal @@ -23,11 +23,13 @@ flag ghc-lib library default-language: Haskell2010 build-depends: - base < 4.15, array, bytestring, containers, directory, filepath, transformers + base < 4.16, array, bytestring, containers, directory, filepath, transformers if flag(ghc-lib) build-depends: ghc-lib else build-depends: ghc, ghc-boot + if (impl(ghc >= 9.0) && impl(ghc < 9.1)) + ghc-options: -Wall -Wno-name-shadowing exposed-modules: Compat.HieAst @@ -38,8 +40,10 @@ library if (impl(ghc > 8.5) && impl(ghc < 8.7) && !flag(ghc-lib)) hs-source-dirs: src-ghc86 - if (impl(ghc > 8.7) && impl(ghc < 8.10)) + if (impl(ghc > 8.7) && impl(ghc < 8.10)) hs-source-dirs: src-ghc88 src-reexport - if (impl(ghc > 8.9) && impl(ghc < 8.11) || flag(ghc-lib)) + if (impl(ghc > 8.9) && impl(ghc < 8.11)) hs-source-dirs: src-ghc810 src-reexport + if (impl(ghc >= 9.0) && impl(ghc < 9.1) || flag(ghc-lib)) + hs-source-dirs: src-ghc901 diff --git a/hie-compat/src-ghc901/Compat/HieAst.hs b/hie-compat/src-ghc901/Compat/HieAst.hs new file mode 100644 index 0000000000..26f315caef --- /dev/null +++ b/hie-compat/src-ghc901/Compat/HieAst.hs @@ -0,0 +1,35 @@ +{- +Forked from GHC v9.0.1 to work around the readFile side effect in mkHiefile + +Main functions for .hie file generation +-} +{- HLINT ignore -} +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +module Compat.HieAst ( mkHieFile, enrichHie ) where + +import GHC.Data.Maybe (expectJust) +import GHC.Driver.Types +import GHC.Hs +import GHC.Tc.Types (TcGblEnv) +import GHC.Types.Avail (Avails) +import GHC.Unit.Module (ml_hs_file) + +import GHC.Iface.Ext.Ast (enrichHie, mkHieFileWithSource) +import GHC.Iface.Ext.Types + +import qualified Data.ByteString as BS + + +type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn] + , Maybe [(LIE GhcRn, Avails)] + , Maybe LHsDocString ) + +-- | Construct an 'HieFile' from the outputs of the typechecker. +mkHieFile :: ModSummary + -> TcGblEnv + -> RenamedSource + -> BS.ByteString -> Hsc HieFile +mkHieFile ms ts rs src = do + let src_file = expectJust "mkHieFile" (ml_hs_file $ ms_location ms) + mkHieFileWithSource src_file src ms ts rs diff --git a/hie-compat/src-ghc901/Compat/HieBin.hs b/hie-compat/src-ghc901/Compat/HieBin.hs new file mode 100644 index 0000000000..254e1db6d3 --- /dev/null +++ b/hie-compat/src-ghc901/Compat/HieBin.hs @@ -0,0 +1,8 @@ +{- +Binary serialization for .hie files. +-} + +module Compat.HieBin ( module GHC.Iface.Ext.Binary) +where + +import GHC.Iface.Ext.Binary diff --git a/hie-compat/src-ghc901/Compat/HieDebug.hs b/hie-compat/src-ghc901/Compat/HieDebug.hs new file mode 100644 index 0000000000..872da67c2b --- /dev/null +++ b/hie-compat/src-ghc901/Compat/HieDebug.hs @@ -0,0 +1,10 @@ +module Compat.HieDebug + ( module GHC.Iface.Ext.Debug + , ppHie ) where +import GHC.Iface.Ext.Debug + +import GHC.Iface.Ext.Types (HieAST) +import GHC.Utils.Outputable (Outputable(ppr), SDoc) + +ppHie :: Outputable a => HieAST a -> SDoc +ppHie = ppr diff --git a/hie-compat/src-ghc901/Compat/HieTypes.hs b/hie-compat/src-ghc901/Compat/HieTypes.hs new file mode 100644 index 0000000000..36bb86abeb --- /dev/null +++ b/hie-compat/src-ghc901/Compat/HieTypes.hs @@ -0,0 +1,3 @@ +module Compat.HieTypes + ( module GHC.Iface.Ext.Types ) where +import GHC.Iface.Ext.Types diff --git a/hie-compat/src-ghc901/Compat/HieUtils.hs b/hie-compat/src-ghc901/Compat/HieUtils.hs new file mode 100644 index 0000000000..204a312039 --- /dev/null +++ b/hie-compat/src-ghc901/Compat/HieUtils.hs @@ -0,0 +1,3 @@ +module Compat.HieUtils + ( module GHC.Iface.Ext.Utils ) where +import GHC.Iface.Ext.Utils