Skip to content

Commit 88548ac

Browse files
authored
hie-compat: Add basic support for ghc 9.0.1 (#1635)
* hie-compat: Add basic support for ghc-9.0.1 A tiny step towards #297 * hie-compat: Remove dependency on ghc-api-compat * hie-compat: Add more backwards compatability * Don't needlessly duplicate code from ghc * hie-compat: Reexport the original version of HieBin
1 parent 5949390 commit 88548ac

File tree

6 files changed

+66
-3
lines changed

6 files changed

+66
-3
lines changed

hie-compat/hie-compat.cabal

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ flag ghc-lib
2323
library
2424
default-language: Haskell2010
2525
build-depends:
26-
base < 4.15, array, bytestring, containers, directory, filepath, transformers
26+
base < 4.16, array, bytestring, containers, directory, filepath, transformers
2727
if flag(ghc-lib)
2828
build-depends: ghc-lib
2929
else
3030
build-depends: ghc, ghc-boot
31+
if (impl(ghc >= 9.0) && impl(ghc < 9.1))
32+
ghc-options: -Wall -Wno-name-shadowing
3133

3234
exposed-modules:
3335
Compat.HieAst
@@ -38,8 +40,10 @@ library
3840

3941
if (impl(ghc > 8.5) && impl(ghc < 8.7) && !flag(ghc-lib))
4042
hs-source-dirs: src-ghc86
41-
if (impl(ghc > 8.7) && impl(ghc < 8.10))
43+
if (impl(ghc > 8.7) && impl(ghc < 8.10))
4244
hs-source-dirs: src-ghc88 src-reexport
43-
if (impl(ghc > 8.9) && impl(ghc < 8.11) || flag(ghc-lib))
45+
if (impl(ghc > 8.9) && impl(ghc < 8.11))
4446
hs-source-dirs: src-ghc810 src-reexport
47+
if (impl(ghc >= 9.0) && impl(ghc < 9.1) || flag(ghc-lib))
48+
hs-source-dirs: src-ghc901
4549

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{-
2+
Forked from GHC v9.0.1 to work around the readFile side effect in mkHiefile
3+
4+
Main functions for .hie file generation
5+
-}
6+
{- HLINT ignore -}
7+
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
8+
9+
module Compat.HieAst ( mkHieFile, enrichHie ) where
10+
11+
import GHC.Data.Maybe (expectJust)
12+
import GHC.Driver.Types
13+
import GHC.Hs
14+
import GHC.Tc.Types (TcGblEnv)
15+
import GHC.Types.Avail (Avails)
16+
import GHC.Unit.Module (ml_hs_file)
17+
18+
import GHC.Iface.Ext.Ast (enrichHie, mkHieFileWithSource)
19+
import GHC.Iface.Ext.Types
20+
21+
import qualified Data.ByteString as BS
22+
23+
24+
type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn]
25+
, Maybe [(LIE GhcRn, Avails)]
26+
, Maybe LHsDocString )
27+
28+
-- | Construct an 'HieFile' from the outputs of the typechecker.
29+
mkHieFile :: ModSummary
30+
-> TcGblEnv
31+
-> RenamedSource
32+
-> BS.ByteString -> Hsc HieFile
33+
mkHieFile ms ts rs src = do
34+
let src_file = expectJust "mkHieFile" (ml_hs_file $ ms_location ms)
35+
mkHieFileWithSource src_file src ms ts rs
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{-
2+
Binary serialization for .hie files.
3+
-}
4+
5+
module Compat.HieBin ( module GHC.Iface.Ext.Binary)
6+
where
7+
8+
import GHC.Iface.Ext.Binary
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Compat.HieDebug
2+
( module GHC.Iface.Ext.Debug
3+
, ppHie ) where
4+
import GHC.Iface.Ext.Debug
5+
6+
import GHC.Iface.Ext.Types (HieAST)
7+
import GHC.Utils.Outputable (Outputable(ppr), SDoc)
8+
9+
ppHie :: Outputable a => HieAST a -> SDoc
10+
ppHie = ppr
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Compat.HieTypes
2+
( module GHC.Iface.Ext.Types ) where
3+
import GHC.Iface.Ext.Types
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Compat.HieUtils
2+
( module GHC.Iface.Ext.Utils ) where
3+
import GHC.Iface.Ext.Utils

0 commit comments

Comments
 (0)