ghc-9.4.3: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Driver.Env

Synopsis

Documentation

newtype Hsc a Source #

The Hsc monad: Passing an environment and diagnostic state

Constructors

Hsc (HscEnv -> Messages GhcMessage -> IO (a, Messages GhcMessage)) 

Instances

Instances details
MonadIO Hsc Source # 
Instance details

Defined in GHC.Driver.Env.Types

Methods

liftIO :: IO a -> Hsc a Source #

Applicative Hsc Source # 
Instance details

Defined in GHC.Driver.Env.Types

Methods

pure :: a -> Hsc a Source #

(<*>) :: Hsc (a -> b) -> Hsc a -> Hsc b Source #

liftA2 :: (a -> b -> c) -> Hsc a -> Hsc b -> Hsc c Source #

(*>) :: Hsc a -> Hsc b -> Hsc b Source #

(<*) :: Hsc a -> Hsc b -> Hsc a Source #

Functor Hsc Source # 
Instance details

Defined in GHC.Driver.Env.Types

Methods

fmap :: (a -> b) -> Hsc a -> Hsc b Source #

(<$) :: a -> Hsc b -> Hsc a Source #

Monad Hsc Source # 
Instance details

Defined in GHC.Driver.Env.Types

Methods

(>>=) :: Hsc a -> (a -> Hsc b) -> Hsc b Source #

(>>) :: Hsc a -> Hsc b -> Hsc b Source #

return :: a -> Hsc a Source #

HasDynFlags Hsc Source # 
Instance details

Defined in GHC.Driver.Env.Types

HasLogger Hsc Source # 
Instance details

Defined in GHC.Driver.Env.Types

data HscEnv Source #

HscEnv is like Session, except that some of the fields are immutable. An HscEnv is used to compile a single module from plain Haskell source code (after preprocessing) to either C, assembly or C--. It's also used to store the dynamic linker state to allow for multiple linkers in the same address space. Things like the module graph don't change during a single compilation.

Historical note: "hsc" used to be the name of the compiler binary, when there was a separate driver and compiler. To compile a single module, the driver would invoke hsc on the source code... so nowadays we think of hsc as the layer of the compiler that deals with compiling a single module.

Constructors

HscEnv 

Fields

Instances

Instances details
ContainsDynFlags HscEnv Source # 
Instance details

Defined in GHC.Driver.Env.Types

hscUpdateLoggerFlags :: HscEnv -> HscEnv Source #

Update the LogFlags of the Log in hsc_logger from the DynFlags in hsc_dflags. You need to call this when DynFlags are modified.

runHsc :: HscEnv -> Hsc a -> IO a Source #

mkInteractiveHscEnv :: HscEnv -> HscEnv Source #

Switches in the DynFlags and Plugins from the InteractiveContext

runInteractiveHsc :: HscEnv -> Hsc a -> IO a Source #

A variant of runHsc that switches in the DynFlags and Plugins from the InteractiveContext before running the Hsc computation.

hscEPS :: HscEnv -> IO ExternalPackageState Source #

Retrieve the ExternalPackageState cache.

hscInterp :: HscEnv -> Interp Source #

Retrieve the target code interpreter

Fails if no target code interpreter is available

hptAllInstances :: HscEnv -> (InstEnv, [FamInst]) Source #

Find all the instance declarations (of classes and families) from the Home Package Table filtered by the provided predicate function. Used in tcRnImports, to select the instances that are in the transitive closure of imports from the currently compiled module.

hptInstancesBelow :: HscEnv -> UnitId -> ModuleNameWithIsBoot -> (InstEnv, [FamInst]) Source #

Find instances visible from the given set of imports

hptAnns :: HscEnv -> Maybe (UnitId, ModuleNameWithIsBoot) -> [Annotation] Source #

Get annotations from modules "below" this one (in the dependency sense)

hptAllThings :: (HomeModInfo -> [a]) -> HscEnv -> [a] Source #

hptSomeThingsBelowUs :: (HomeModInfo -> [a]) -> Bool -> HscEnv -> UnitId -> ModuleNameWithIsBoot -> [a] Source #

Get things from modules "below" this one (in the dependency sense) C.f Inst.hptInstances

hptRules :: HscEnv -> UnitId -> ModuleNameWithIsBoot -> [CoreRule] Source #

Get rules from modules "below" this one (in the dependency sense)

prepareAnnotations :: HscEnv -> Maybe ModGuts -> IO AnnEnv Source #

Deal with gathering annotations in from all possible places and combining them into a single AnnEnv

discardIC :: HscEnv -> HscEnv Source #

Discard the contents of the InteractiveContext, but keep the DynFlags and the loaded plugins. It will also keep ic_int_print and ic_monad if their names are from external packages.

lookupType :: HscEnv -> Name -> IO (Maybe TyThing) Source #

Find the TyThing for the given Name by using all the resources at our disposal: the compiled modules in the HomePackageTable and the compiled modules in other packages that live in PackageTypeEnv. Note that this does NOT look up the TyThing in the module being compiled: you have to do that yourself, if desired

lookupIfaceByModule :: HomeUnitGraph -> PackageIfaceTable -> Module -> Maybe ModIface Source #

Find the ModIface for a GenModule, searching in both the loaded home and external package module information