Skip to content

Commit d2e0bcd

Browse files
committed
Add GHC 9.2 support hie-compat
1 parent 9207050 commit d2e0bcd

File tree

6 files changed

+63
-0
lines changed

6 files changed

+63
-0
lines changed

hie-compat/hie-compat.cabal

+3
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ library
4646
hs-source-dirs: src-ghc810 src-reexport
4747
if (impl(ghc >= 9.0) && impl(ghc < 9.1) || flag(ghc-lib))
4848
hs-source-dirs: src-ghc901
49+
if (impl(ghc >= 9.2) && impl(ghc < 9.3))
50+
hs-source-dirs: src-ghc902
51+
4952

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{-
2+
Forked from GHC v9.2.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.Env
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+
import GHC.Unit.Module.ModSummary (ModSummary(..))
18+
19+
import GHC.Iface.Ext.Ast (enrichHie, mkHieFileWithSource)
20+
import GHC.Iface.Ext.Types
21+
22+
import qualified Data.ByteString as BS
23+
24+
25+
type RenamedSource = ( HsGroup GhcRn, [LImportDecl GhcRn]
26+
, Maybe [(LIE GhcRn, Avails)]
27+
, Maybe LHsDocString )
28+
29+
-- | Construct an 'HieFile' from the outputs of the typechecker.
30+
mkHieFile :: ModSummary
31+
-> TcGblEnv
32+
-> RenamedSource
33+
-> BS.ByteString -> Hsc HieFile
34+
mkHieFile ms ts rs src = do
35+
let src_file = expectJust "mkHieFile" (ml_hs_file $ ms_location ms)
36+
mkHieFileWithSource src_file src ms ts rs
+8
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
+10
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
+3
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
+3
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)