Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hie-compat: Add basic support for ghc 9.0.1 #1635

Merged
merged 5 commits into from
May 31, 2021
Merged
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
10 changes: 7 additions & 3 deletions hie-compat/hie-compat.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

35 changes: 35 additions & 0 deletions hie-compat/src-ghc901/Compat/HieAst.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{-
Forked from GHC v9.0.1 to work around the readFile side effect in mkHiefile
anka-213 marked this conversation as resolved.
Show resolved Hide resolved

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
8 changes: 8 additions & 0 deletions hie-compat/src-ghc901/Compat/HieBin.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be duplicated? I think it should be possible to just reexport GHC.Iface.Ext.Binary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I just copied whatever was in the ghc-810 versions and updated it to the ghc-901 version.

Binary serialization for .hie files.
-}

module Compat.HieBin ( module GHC.Iface.Ext.Binary)
where

import GHC.Iface.Ext.Binary
10 changes: 10 additions & 0 deletions hie-compat/src-ghc901/Compat/HieDebug.hs
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions hie-compat/src-ghc901/Compat/HieTypes.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Compat.HieTypes
( module GHC.Iface.Ext.Types ) where
import GHC.Iface.Ext.Types
3 changes: 3 additions & 0 deletions hie-compat/src-ghc901/Compat/HieUtils.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Compat.HieUtils
( module GHC.Iface.Ext.Utils ) where
import GHC.Iface.Ext.Utils