Skip to content
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
22 changes: 19 additions & 3 deletions ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ module Language.Haskell.GHC.Parser (
import Data.List (intercalate, findIndex, isInfixOf)
import Data.Char (isAlphaNum)

#if MIN_VERSION_ghc(9,8,0)
#if MIN_VERSION_ghc(9,14,0)
import GHC.Driver.Config.Parser (initParserOpts)
import GHC.Driver.Session (supportedLanguagesAndExtensions)
import GHC.Parser.Errors.Types (PsMessage(..))
import GHC.Platform (platformArchOS)
import GHC.Types.Error (defaultDiagnosticOpts, getMessages, MsgEnvelope(..))
import GHC.Utils.Error (diagnosticMessage, formatBulleted)
import GHC.Utils.Logger (initLogger)
import GHC.Utils.Outputable (defaultSDocContext, renderWithContext)
#elif MIN_VERSION_ghc(9,8,0)
import GHC.Driver.Config.Parser (initParserOpts)
import GHC.Parser.Errors.Types (PsMessage(..))
import GHC.Types.Error (defaultDiagnosticOpts, getMessages, MsgEnvelope(..))
Expand Down Expand Up @@ -215,12 +224,19 @@ runParser flags (Parser parser) str =
parsePragmasIntoDynFlags :: DynFlags -> FilePath -> String -> IO (Maybe DynFlags)
parsePragmasIntoDynFlags flags filepath str =
catchErrors $ do
#if MIN_VERSION_ghc(9,4,0)
#if MIN_VERSION_ghc(9,14,0)
-- GHC 9.14 made getOptions take the supported pragmas and parseDynamicFilePragma take a Logger.
let supported = supportedLanguagesAndExtensions (platformArchOS (targetPlatform flags))
let opts = snd $ getOptions (initParserOpts flags) supported (stringToStringBuffer str) filepath
logger <- initLogger
(flags', _, _) <- parseDynamicFilePragma logger flags opts
#elif MIN_VERSION_ghc(9,4,0)
let opts = snd $ getOptions (initParserOpts flags) (stringToStringBuffer str) filepath
(flags', _, _) <- parseDynamicFilePragma flags opts
#else
let opts = getOptions flags (stringToStringBuffer str) filepath
#endif
(flags', _, _) <- parseDynamicFilePragma flags opts
#endif
return $ Just flags'
where
catchErrors :: IO (Maybe DynFlags) -> IO (Maybe DynFlags)
Expand Down
4 changes: 2 additions & 2 deletions ghc-parser/ghc-parser.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ library
-- other-modules:
-- other-extensions:
build-depends: base >=4.9 && < 5,
ghc >=8.4 && <9.14
ghc >=8.4 && <9.16

if impl(ghc >= 8.4) && impl(ghc < 8.10)
hs-source-dirs: generic-src src-8.4
Expand All @@ -37,7 +37,7 @@ library
hs-source-dirs: generic-src src-9.4
if impl(ghc >= 9.6) && impl(ghc < 9.8)
hs-source-dirs: generic-src src-9.6
if impl(ghc >= 9.8) && impl(ghc < 9.14)
if impl(ghc >= 9.8) && impl(ghc < 9.16)
hs-source-dirs: generic-src src-9.8


Expand Down
2 changes: 1 addition & 1 deletion ihaskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ library
bytestring ,
exceptions ,
filepath ,
ghc >=8.4 && <9.13,
ghc >=8.4 && <9.16,
ghc-boot ,
haskeline ,
parsec ,
Expand Down
5 changes: 5 additions & 0 deletions src/IHaskell/Eval/Evaluate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import HscTypes
import InteractiveEval
import Exception hiding (evaluate)
import GhcMonad (liftIO)

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.8.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.8.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.10.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.10.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.10.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.10.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.8.yaml)

The import of ‘GhcMonad’ is redundant

Check warning on line 87 in src/IHaskell/Eval/Evaluate.hs

View workflow job for this annotation

GitHub Actions / linux (stack/stack-8.8.yaml)

The import of ‘GhcMonad’ is redundant
import Outputable hiding ((<>))
import Packages
import qualified ErrUtils
Expand Down Expand Up @@ -637,7 +637,12 @@
-- Get the dot-delimited pieces of the module name.
moduleNameOf :: InteractiveImport -> [String]
moduleNameOf (IIDecl decl) = split "." . moduleNameString . unLoc . ideclName $ decl
#if MIN_VERSION_ghc(9,14,0)
-- GHC 9.14 changed IIModule to carry a Module rather than a ModuleName.
moduleNameOf (IIModule imp) = split "." . moduleNameString . moduleName $ imp
#else
moduleNameOf (IIModule imp) = split "." . moduleNameString $ imp
#endif

-- Return whether this module prevents the loading of the one we're trying to load. If a module B
-- exist, we cannot load A.B. All modules must have unique last names (where A.B has last name B).
Expand Down
5 changes: 5 additions & 0 deletions src/IHaskell/Eval/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,12 @@ removeImport modName = do

where
isImportOf :: ModuleName -> InteractiveImport -> Bool
#if MIN_VERSION_ghc(9,14,0)
-- GHC 9.14 changed IIModule to carry a Module rather than a ModuleName.
isImportOf name (IIModule m) = name == moduleName m
#else
isImportOf name (IIModule mName) = name == mName
#endif
isImportOf name (IIDecl impDecl) = name == unLoc (ideclName impDecl)

-- | Evaluate a series of declarations. Return all names which were bound by these declarations.
Expand Down
Loading