HIE.Bios.Ghc.Gap

hie-bios-0.14.0: Set up a GHC API session

Safe Haskell | None
Language | Haskell2010

HIE.Bios.Ghc.Gap

Contents

- Warnings, Doc Compat
- Argument parsing
- Ghc Monad
- Hsc Monad
- Driver compat
- HscEnv Compat
- AST compat
- Exceptions
- Doc Gap functions
- DynFlags compat
- Platform constants
- misc

Description

All the CPP for GHC version compability should live in this module.

Synopsis

- ghcVersion :: String
- makeUserStyle :: DynFlags -> NamePprCtx -> PprStyle
- data PprStyle
- parseTargetFiles :: DynFlags -> [String] -> (DynFlags, [(String, Maybe Phase)], [String])
- modifySession :: GhcMonad m => (HscEnv -> HscEnv) -> m ()
- reflectGhc :: Ghc a -> Session -> IO a
- data Session = Session !(IORef HscEnv)
- getHscEnv :: Hsc HscEnv
- batchMsg :: Messager
- set_hsc_dflags :: DynFlags -> HscEnv -> HscEnv
- overPkgDbRef :: (FilePath -> FilePath) -> PackageDBFlag -> PackageDBFlag
- guessTarget :: GhcMonad m => String -> Maybe UnitId -> Maybe Phase -> m Target
- setNoCode :: DynFlags -> DynFlags
- getModSummaries :: ModuleGraph -> [ModSummary]
- mapOverIncludePaths :: (FilePath -> FilePath) -> DynFlags -> DynFlags
- getLogger :: HscEnv -> Logger
- pattern RealSrcSpan :: RealSrcSpan -> SrcSpan
- catch :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a
- bracket :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b
- handle :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a
- pageMode :: Mode
- oneLineMode :: Mode
- initializePluginsForModSummary :: HscEnv -> ModSummary -> IO (Int, [ModuleName], ModSummary)
- setFrontEndHooks :: Maybe (ModSummary -> Hsc FrontendResult) -> HscEnv -> HscEnv
- updOptLevel :: Int -> DynFlags -> DynFlags
- setWayDynamicIfHostIsDynamic :: DynFlags -> DynFlags
- gopt_set :: DynFlags -> GeneralFlag -> DynFlags
- parseDynamicFlags :: MonadIO m => Logger -> DynFlags -> [Located String] -> m (DynFlags, [Located String], Messages DriverMessage)
- hostIsDynamic :: Bool
- getTyThing :: (a, b, c, d, e) -> a
- fixInfo :: (a, b, c, d, e) -> (a, b, c, d)
- data FrontendResult = FrontendTypecheck TcGblEnv
- data Hsc a
- mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph
- mgModSummaries :: ModuleGraph -> [ModSummary]
- unsetLogAction :: GhcMonad m => m ()
- load' :: GhcMonad m => Maybe ModIfaceCache -> LoadHowMuch -> Maybe Messager -> ModuleGraph -> m SuccessFlag
- homeUnitId_ :: DynFlags -> UnitId
- getDynFlags :: HasDynFlags m => m DynFlags

# Documentation

ghcVersion :: String #

# Warnings, Doc Compat

makeUserStyle :: DynFlags -> NamePprCtx -> PprStyle #

data PprStyle #

#### Instances

Instances details

Outputable PprStyle |
Instance details Defined in GHC.Utils.Outputable Methods ppr :: PprStyle -> SDoc #

# Argument parsing

parseTargetFiles :: DynFlags -> [String] -> (DynFlags, [(String, Maybe Phase)], [String]) #

# Ghc Monad

modifySession :: GhcMonad m => (HscEnv -> HscEnv) -> m () #

Set the current session to the result of applying the current session to the argument.

reflectGhc :: Ghc a -> Session -> IO a #

Reflect a computation in the `Ghc` monad into the `IO` monad.

You can use this to call functions returning an action in the `Ghc` monad inside an `IO` action. This is needed for some (too restrictive) callback arguments of some library functions:

    libFunc :: String -> (Int -> IO a) -> IO a
    ghcFunc :: Int -> Ghc a

    ghcFuncUsingLibFunc :: String -> Ghc a -> Ghc a
    ghcFuncUsingLibFunc str =
      reifyGhc $ \s ->
        libFunc $ \i -> do
          reflectGhc (ghcFunc i) s

data Session #

The Session is a handle to the complete state of a compilation session. A compilation session consists of a set of modules constituting the current program or library, the context for interactive evaluation, and various caches.

Constructors

Session !(IORef HscEnv) |

# Hsc Monad

getHscEnv :: Hsc HscEnv #

# Driver compat

batchMsg :: Messager #

# HscEnv Compat

set_hsc_dflags :: DynFlags -> HscEnv -> HscEnv #

overPkgDbRef :: (FilePath -> FilePath) -> PackageDBFlag -> PackageDBFlag #

guessTarget :: GhcMonad m => String -> Maybe UnitId -> Maybe Phase -> m Target #

setNoCode :: DynFlags -> DynFlags #

getModSummaries :: ModuleGraph -> [ModSummary] #

mapOverIncludePaths :: (FilePath -> FilePath) -> DynFlags -> DynFlags #

getLogger :: HscEnv -> Logger #

# AST compat

pattern RealSrcSpan :: RealSrcSpan -> SrcSpan #

# Exceptions

catch :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a #

bracket :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b #

handle :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a #

# Doc Gap functions

pageMode :: Mode #

oneLineMode :: Mode #

# DynFlags compat

initializePluginsForModSummary :: HscEnv -> ModSummary -> IO (Int, [ModuleName], ModSummary) #

setFrontEndHooks :: Maybe (ModSummary -> Hsc FrontendResult) -> HscEnv -> HscEnv #

updOptLevel :: Int -> DynFlags -> DynFlags #

Sets the `DynFlags` to be appropriate to the optimisation level

setWayDynamicIfHostIsDynamic :: DynFlags -> DynFlags #

gopt_set :: DynFlags -> GeneralFlag -> DynFlags #

parseDynamicFlags :: MonadIO m => Logger -> DynFlags -> [Located String] -> m (DynFlags, [Located String], Messages DriverMessage) #

# Platform constants

hostIsDynamic :: Bool #

# misc

getTyThing :: (a, b, c, d, e) -> a #

fixInfo :: (a, b, c, d, e) -> (a, b, c, d) #

data FrontendResult #

`FrontendResult` describes the result of running the frontend of a Haskell module. Currently one always gets a `FrontendTypecheck`, since running the frontend involves typechecking a program. hs-sig merges are not handled here.

This data type really should be in GHC.Driver.Env, but it needs to have a TcGblEnv which is only defined here.

Constructors

FrontendTypecheck TcGblEnv |

data Hsc a #

The Hsc monad: Passing an environment and diagnostic state

#### Instances

Instances details

MonadIO Hsc |
Instance details Defined in GHC.Driver.Env.Types Methods liftIO :: IO a -> Hsc a #
HasDynFlags Hsc |
Instance details Defined in GHC.Driver.Env.Types Methods getDynFlags :: Hsc DynFlags #
HasLogger Hsc |
Instance details Defined in GHC.Driver.Env.Types Methods getLogger :: Hsc Logger #
Applicative Hsc |
Instance details Defined in GHC.Driver.Env.Types Methods pure :: a -> Hsc a # (<*>) :: Hsc (a -> b) -> Hsc a -> Hsc b # liftA2 :: (a -> b -> c) -> Hsc a -> Hsc b -> Hsc c # (*>) :: Hsc a -> Hsc b -> Hsc b # (<*) :: Hsc a -> Hsc b -> Hsc a #
Functor Hsc |
Instance details Defined in GHC.Driver.Env.Types Methods fmap :: (a -> b) -> Hsc a -> Hsc b # (<$) :: a -> Hsc b -> Hsc a #
Monad Hsc |
Instance details Defined in GHC.Driver.Env.Types Methods (>>=) :: Hsc a -> (a -> Hsc b) -> Hsc b # (>>) :: Hsc a -> Hsc b -> Hsc b # return :: a -> Hsc a #

mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph #

Map a function `f` over all the `ModSummaries`. To preserve invariants `f` can't change the isBoot status.

mgModSummaries :: ModuleGraph -> [ModSummary] #

unsetLogAction :: GhcMonad m => m () #

load' :: GhcMonad m => Maybe ModIfaceCache -> LoadHowMuch -> Maybe Messager -> ModuleGraph -> m SuccessFlag #

homeUnitId_ :: DynFlags -> UnitId #

Target home unit-id

getDynFlags :: HasDynFlags m => m DynFlags #