GHC.Driver.Env.Types

ghc-9.4.0.20220501: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Driver.Env.Types

Synopsis

- newtype Hsc a = Hsc (HscEnv -> Messages GhcMessage -> IO (a, Messages GhcMessage))
- data HscEnv = HscEnv {
  - hsc_dflags :: DynFlags
  - hsc_targets :: [Target]
  - hsc_mod_graph :: ModuleGraph
  - hsc_IC :: InteractiveContext
  - hsc_NC :: !NameCache
  - hsc_FC :: !FinderCache
  - hsc_type_env_vars :: KnotVars (IORef TypeEnv)
  - hsc_interp :: Maybe Interp
  - hsc_plugins :: !Plugins
  - hsc_unit_env :: UnitEnv
  - hsc_logger :: !Logger
  - hsc_hooks :: !Hooks
  - hsc_tmpfs :: !TmpFs
  }

# 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 Methods getDynFlags :: Hsc DynFlags Source #
HasLogger Hsc Source # |
Instance details Defined in GHC.Driver.Env.Types Methods getLogger :: Hsc Logger Source #

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 hsc_dflags :: DynFlags The dynamic flag settings hsc_targets :: [Target] The targets (or roots) of the current session hsc_mod_graph :: ModuleGraph The module graph of the current session hsc_IC :: InteractiveContext The context for evaluating interactive statements hsc_NC :: !NameCache Global Name cache so that each Name gets a single Unique. Also track the origin of the Names. hsc_FC :: !FinderCache The cached result of performing finding in the file system hsc_type_env_vars :: KnotVars (IORef TypeEnv) Used for one-shot compilation only, to initialise the `IfGblEnv`. See `tcg_type_env_var` for `TcGblEnv`. See also Note [hsc_type_env_var hack] hsc_interp :: Maybe Interp target code interpreter (if any) to use for TH and GHCi. See Note [Target code interpreter] hsc_plugins :: !Plugins Plugins hsc_unit_env :: UnitEnv Unit environment (unit state, home unit, etc.). Initialized from the databases cached in `hsc_unit_dbs` and from the DynFlags. hsc_logger :: !Logger Logger with its flags. Don't forget to update the logger flags if the logging related DynFlags change. Or better, use hscSetFlags setter which does it. hsc_hooks :: !Hooks Hooks hsc_tmpfs :: !TmpFs Temporary files

#### Instances

Instances details

ContainsDynFlags HscEnv Source # |
Instance details Defined in GHC.Driver.Env.Types Methods extractDynFlags :: HscEnv -> DynFlags Source #