HscTypes
Contents
Ghc
monad stuff- Sessions and compilation state
- Information about modules
- Information about the module being compiled
- State relating to modules in this package
- State relating to known packages
- Annotations
- Interactive context
- Interfaces
- Fixity
- TyThings and type environments
- MonadThings
- Information on imports and exports
- Warnings
- Linker stuff
- Program coverage
- Breakpoints
- Vectorisation information
Description
Types for the per-module compiler
- newtype Ghc a = Ghc {}
- newtype GhcT m a = GhcT {}
- liftGhcT :: Monad m => m a -> GhcT m a
- class (Functor m, MonadIO m, WarnLogMonad m, ExceptionMonad m) => GhcMonad m where
- getSession :: m HscEnv
- setSession :: HscEnv -> m ()
- class Monad m => WarnLogMonad m where
- setWarnings :: WarningMessages -> m ()
- getWarnings :: m WarningMessages
- liftIO :: MonadIO m => IO a -> m a
- ioMsgMaybe :: GhcMonad m => IO (Messages, Maybe a) -> m a
- ioMsg :: GhcMonad m => IO (Messages, a) -> m a
- logWarnings :: WarnLogMonad m => WarningMessages -> m ()
- clearWarnings :: WarnLogMonad m => m ()
- hasWarnings :: WarnLogMonad m => m Bool
- data SourceError
- data GhcApiError
- mkSrcErr :: ErrorMessages -> SourceError
- srcErrorMessages :: SourceError -> ErrorMessages
- mkApiErr :: SDoc -> GhcApiError
- throwOneError :: MonadIO m => ErrMsg -> m ab
- handleSourceError :: ExceptionMonad m => (SourceError -> m a) -> m a -> m a
- reflectGhc :: Ghc a -> Session -> IO a
- reifyGhc :: (Session -> IO a) -> Ghc a
- handleFlagWarnings :: GhcMonad m => DynFlags -> [Located String] -> m ()
- data Session = Session !(IORef HscEnv) !(IORef WarningMessages)
- withSession :: GhcMonad m => (HscEnv -> m a) -> m a
- modifySession :: GhcMonad m => (HscEnv -> HscEnv) -> m ()
- withTempSession :: GhcMonad m => (HscEnv -> HscEnv) -> m a -> m a
- data HscEnv = HscEnv {
- hsc_dflags :: DynFlags
- hsc_callbacks :: GhcApiCallbacks
- hsc_targets :: [Target]
- hsc_mod_graph :: ModuleGraph
- hsc_IC :: InteractiveContext
- hsc_HPT :: HomePackageTable
- hsc_EPS :: !(IORef ExternalPackageState)
- hsc_NC :: !(IORef NameCache)
- hsc_FC :: !(IORef FinderCache)
- hsc_MLC :: !(IORef ModLocationCache)
- hsc_OptFuel :: OptFuelState
- hsc_type_env_var :: Maybe (Module, IORef TypeEnv)
- hscEPS :: HscEnv -> IO ExternalPackageState
- type FinderCache = ModuleNameEnv FindResult
- data FindResult
- = Found ModLocation Module
- | NoPackage PackageId
- | FoundMultiple [PackageId]
- | NotFound [FilePath] (Maybe PackageId) [PackageId] [PackageId]
- | NotFoundInPackage PackageId
- type ModLocationCache = ModuleEnv ModLocation
- data Target = Target {}
- data TargetId
- pprTarget :: Target -> SDoc
- pprTargetId :: TargetId -> SDoc
- type ModuleGraph = [ModSummary]
- emptyMG :: ModuleGraph
- data GhcApiCallbacks = GhcApiCallbacks {
- reportModuleCompilationResult :: GhcMonad m => ModSummary -> Maybe SourceError -> m ()
- withLocalCallbacks :: GhcMonad m => (GhcApiCallbacks -> GhcApiCallbacks) -> m a -> m a
- data ModDetails = ModDetails {
- md_exports :: [AvailInfo]
- md_types :: !TypeEnv
- md_insts :: ![Instance]
- md_fam_insts :: ![FamInst]
- md_rules :: ![CoreRule]
- md_anns :: ![Annotation]
- md_vect_info :: !VectInfo
- emptyModDetails :: ModDetails
- data ModGuts = ModGuts {
- mg_module :: !Module
- mg_boot :: IsBootInterface
- mg_exports :: ![AvailInfo]
- mg_deps :: !Dependencies
- mg_dir_imps :: !ImportedMods
- mg_used_names :: !NameSet
- mg_rdr_env :: !GlobalRdrEnv
- mg_fix_env :: !FixityEnv
- mg_types :: !TypeEnv
- mg_insts :: ![Instance]
- mg_fam_insts :: ![FamInst]
- mg_rules :: ![CoreRule]
- mg_binds :: ![CoreBind]
- mg_foreign :: !ForeignStubs
- mg_warns :: !Warnings
- mg_anns :: [Annotation]
- mg_hpc_info :: !HpcInfo
- mg_modBreaks :: !ModBreaks
- mg_vect_info :: !VectInfo
- mg_inst_env :: InstEnv
- mg_fam_inst_env :: FamInstEnv
- data CoreModule = CoreModule {}
- data CgGuts = CgGuts {
- cg_module :: !Module
- cg_tycons :: [TyCon]
- cg_binds :: [CoreBind]
- cg_dir_imps :: ![Module]
- cg_foreign :: !ForeignStubs
- cg_dep_pkgs :: ![PackageId]
- cg_hpc_info :: !HpcInfo
- cg_modBreaks :: !ModBreaks
- data ForeignStubs
- = NoStubs
- | ForeignStubs SDoc SDoc
- type ImportedMods = ModuleEnv [(ModuleName, Bool, SrcSpan)]
- data ModSummary = ModSummary {}
- ms_mod_name :: ModSummary -> ModuleName
- showModMsg :: HscTarget -> Bool -> ModSummary -> String
- isBootSummary :: ModSummary -> Bool
- msHsFilePath :: ModSummary -> FilePath
- msHiFilePath :: ModSummary -> FilePath
- msObjFilePath :: ModSummary -> FilePath
- data HscSource
- = HsSrcFile
- | HsBootFile
- | ExtCoreFile
- isHsBoot :: HscSource -> Bool
- hscSourceString :: HscSource -> String
- type HomePackageTable = ModuleNameEnv HomeModInfo
- data HomeModInfo = HomeModInfo {
- hm_iface :: !ModIface
- hm_details :: !ModDetails
- hm_linkable :: !(Maybe Linkable)
- emptyHomePackageTable :: HomePackageTable
- hptInstances :: HscEnv -> (ModuleName -> Bool) -> ([Instance], [FamInst])
- hptRules :: HscEnv -> [(ModuleName, IsBootInterface)] -> [CoreRule]
- hptVectInfo :: HscEnv -> VectInfo
- data ExternalPackageState = EPS {
- eps_is_boot :: !(ModuleNameEnv (ModuleName, IsBootInterface))
- eps_PIT :: !PackageIfaceTable
- eps_PTE :: !PackageTypeEnv
- eps_inst_env :: !PackageInstEnv
- eps_fam_inst_env :: !PackageFamInstEnv
- eps_rule_base :: !PackageRuleBase
- eps_vect_info :: !PackageVectInfo
- eps_ann_env :: !PackageAnnEnv
- eps_mod_fam_inst_env :: !(ModuleEnv FamInstEnv)
- eps_stats :: !EpsStats
- data EpsStats = EpsStats {
- n_ifaces_in :: !Int
- n_decls_in :: !Int
- n_decls_out :: !Int
- n_rules_in :: !Int
- n_rules_out :: !Int
- n_insts_in :: !Int
- n_insts_out :: !Int
- addEpsInStats :: EpsStats -> Int -> Int -> Int -> EpsStats
- type PackageTypeEnv = TypeEnv
- type PackageIfaceTable = ModuleEnv ModIface
- emptyPackageIfaceTable :: PackageIfaceTable
- lookupIfaceByModule :: DynFlags -> HomePackageTable -> PackageIfaceTable -> Module -> Maybe ModIface
- emptyModIface :: Module -> ModIface
- type PackageInstEnv = InstEnv
- type PackageRuleBase = RuleBase
- prepareAnnotations :: HscEnv -> Maybe ModGuts -> IO AnnEnv
- data InteractiveContext = InteractiveContext {
- ic_toplev_scope :: [Module]
- ic_exports :: [(Module, Maybe (ImportDecl RdrName))]
- ic_rn_gbl_env :: GlobalRdrEnv
- ic_tmp_ids :: [Id]
- ic_cwd :: Maybe FilePath
- emptyInteractiveContext :: InteractiveContext
- icPrintUnqual :: DynFlags -> InteractiveContext -> PrintUnqualified
- extendInteractiveContext :: InteractiveContext -> [Id] -> InteractiveContext
- substInteractiveContext :: InteractiveContext -> TvSubst -> InteractiveContext
- mkPrintUnqualified :: DynFlags -> GlobalRdrEnv -> PrintUnqualified
- pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc
- data ModIface = ModIface {
- mi_module :: !Module
- mi_iface_hash :: !Fingerprint
- mi_mod_hash :: !Fingerprint
- mi_orphan :: !WhetherHasOrphans
- mi_finsts :: !WhetherHasFamInst
- mi_boot :: !IsBootInterface
- mi_deps :: Dependencies
- mi_usages :: [Usage]
- mi_exports :: ![IfaceExport]
- mi_exp_hash :: !Fingerprint
- mi_fixities :: [(OccName, Fixity)]
- mi_warns :: Warnings
- mi_anns :: [IfaceAnnotation]
- mi_decls :: [(Fingerprint, IfaceDecl)]
- mi_globals :: !(Maybe GlobalRdrEnv)
- mi_insts :: [IfaceInst]
- mi_fam_insts :: [IfaceFamInst]
- mi_rules :: [IfaceRule]
- mi_orphan_hash :: !Fingerprint
- mi_vect_info :: !IfaceVectInfo
- mi_warn_fn :: Name -> Maybe WarningTxt
- mi_fix_fn :: OccName -> Fixity
- mi_hash_fn :: OccName -> Maybe (OccName, Fingerprint)
- mi_hpc :: !AnyHpcUsage
- mkIfaceWarnCache :: Warnings -> Name -> Maybe WarningTxt
- mkIfaceHashCache :: [(Fingerprint, IfaceDecl)] -> OccName -> Maybe (OccName, Fingerprint)
- mkIfaceFixCache :: [(OccName, Fixity)] -> OccName -> Fixity
- emptyIfaceWarnCache :: Name -> Maybe WarningTxt
- type FixityEnv = NameEnv FixItem
- data FixItem = FixItem OccName Fixity
- lookupFixity :: FixityEnv -> Name -> Fixity
- emptyFixityEnv :: FixityEnv
- data TyThing
- tyThingClass :: TyThing -> Class
- tyThingTyCon :: TyThing -> TyCon
- tyThingDataCon :: TyThing -> DataCon
- tyThingId :: TyThing -> Id
- implicitTyThings :: TyThing -> [TyThing]
- isImplicitTyThing :: TyThing -> Bool
- type TypeEnv = NameEnv TyThing
- lookupType :: DynFlags -> HomePackageTable -> PackageTypeEnv -> Name -> Maybe TyThing
- lookupTypeHscEnv :: HscEnv -> Name -> IO (Maybe TyThing)
- mkTypeEnv :: [TyThing] -> TypeEnv
- emptyTypeEnv :: TypeEnv
- extendTypeEnv :: TypeEnv -> TyThing -> TypeEnv
- extendTypeEnvList :: TypeEnv -> [TyThing] -> TypeEnv
- extendTypeEnvWithIds :: TypeEnv -> [Id] -> TypeEnv
- lookupTypeEnv :: TypeEnv -> Name -> Maybe TyThing
- typeEnvElts :: TypeEnv -> [TyThing]
- typeEnvClasses :: TypeEnv -> [Class]
- typeEnvTyCons :: TypeEnv -> [TyCon]
- typeEnvIds :: TypeEnv -> [Id]
- typeEnvDataCons :: TypeEnv -> [DataCon]
- class Monad m => MonadThings m where
- lookupThing :: Name -> m TyThing
- lookupId :: Name -> m Id
- lookupDataCon :: Name -> m DataCon
- lookupTyCon :: Name -> m TyCon
- lookupClass :: Name -> m Class
- type WhetherHasOrphans = Bool
- type IsBootInterface = Bool
- data Usage
- = UsagePackageModule { }
- | UsageHomeModule { }
- data Dependencies = Deps {
- dep_mods :: [(ModuleName, IsBootInterface)]
- dep_pkgs :: [PackageId]
- dep_orphs :: [Module]
- dep_finsts :: [Module]
- noDependencies :: Dependencies
- data NameCache = NameCache {}
- type OrigNameCache = ModuleEnv (OccEnv Name)
- type OrigIParamCache = Map (IPName OccName) (IPName Name)
- type Avails = [AvailInfo]
- availsToNameSet :: [AvailInfo] -> NameSet
- availsToNameEnv :: [AvailInfo] -> NameEnv AvailInfo
- availName :: GenAvailInfo name -> name
- availNames :: GenAvailInfo name -> [name]
- data GenAvailInfo name
- type AvailInfo = GenAvailInfo Name
- type RdrAvailInfo = GenAvailInfo OccName
- type IfaceExport = (Module, [GenAvailInfo OccName])
- data Warnings
- = NoWarnings
- | WarnAll WarningTxt
- | WarnSome [(OccName, WarningTxt)]
- data WarningTxt
- = WarningTxt [FastString]
- | DeprecatedTxt [FastString]
- plusWarns :: Warnings -> Warnings -> Warnings
- data Linkable = LM {}
- isObjectLinkable :: Linkable -> Bool
- data Unlinked
- data CompiledByteCode
- isObject :: Unlinked -> Bool
- nameOfObject :: Unlinked -> FilePath
- isInterpretable :: Unlinked -> Bool
- byteCodeOfObject :: Unlinked -> CompiledByteCode
- data HpcInfo
- emptyHpcInfo :: AnyHpcUsage -> HpcInfo
- isHpcUsed :: HpcInfo -> AnyHpcUsage
- type AnyHpcUsage = Bool
- data ModBreaks = ModBreaks {}
- type BreakIndex = Int
- emptyModBreaks :: ModBreaks
- data VectInfo = VectInfo {
- vectInfoVar :: VarEnv (Var, Var)
- vectInfoTyCon :: NameEnv (TyCon, TyCon)
- vectInfoDataCon :: NameEnv (DataCon, DataCon)
- vectInfoPADFun :: NameEnv (TyCon, Var)
- vectInfoIso :: NameEnv (TyCon, Var)
- data IfaceVectInfo = IfaceVectInfo {
- ifaceVectInfoVar :: [Name]
- ifaceVectInfoTyCon :: [Name]
- ifaceVectInfoTyConReuse :: [Name]
- noVectInfo :: VectInfo
- plusVectInfo :: VectInfo -> VectInfo -> VectInfo
- noIfaceVectInfo :: IfaceVectInfo
Ghc
monad stuff
newtype Ghc a
newtype GhcT m a
A monad transformer to add GHC specific features to another monad.
Note that the wrapped monad must support IO and handling of exceptions.
Instances
Monad m => Monad (GhcT m) | |
Functor m => Functor (GhcT m) | |
ExceptionMonad m => ExceptionMonad (GhcT m) | |
MonadIO m => MonadIO (GhcT m) | |
(Functor m, ExceptionMonad m, MonadIO m) => GhcMonad (GhcT m) | |
MonadIO m => WarnLogMonad (GhcT m) |
class (Functor m, MonadIO m, WarnLogMonad m, ExceptionMonad m) => GhcMonad m where
A monad that has all the features needed by GHC API calls.
In short, a GHC monad
- allows embedding of IO actions,
- can log warnings,
- allows handling of (extensible) exceptions, and
- maintains a current session.
If you do not use Ghc
or GhcT
, make sure to call GHC.initGhcMonad
before any call to the GHC API functions can occur.
class Monad m => WarnLogMonad m where
A monad that allows logging of warnings.
Instances
WarnLogMonad Ghc | |
MonadIO m => WarnLogMonad (GhcT m) |
ioMsgMaybe :: GhcMonad m => IO (Messages, Maybe a) -> m a
Lift an IO action returning errors messages into a GhcMonad
.
In order to reduce dependencies to other parts of the compiler, functions
outside the main parts of GHC return warnings and errors as a parameter
and signal success via by wrapping the result in a Maybe
type. This
function logs the returned warnings and propagates errors as exceptions
(of type SourceError
).
This function assumes the following invariants:
- If the second result indicates success (is of the form 'Just x'), there must be no error messages in the first result.
- If there are no error messages, but the second result indicates failure
there should be warnings in the first result. That is, if the action
failed, it must have been due to the warnings (i.e.,
-Werror
).
ioMsg :: GhcMonad m => IO (Messages, a) -> m a
Lift a non-failing IO action into a GhcMonad
.
Like ioMsgMaybe
, but assumes that the action will never return any error
messages.
logWarnings :: WarnLogMonad m => WarningMessages -> m ()
clearWarnings :: WarnLogMonad m => m ()
Clear the log of Warnings
.
hasWarnings :: WarnLogMonad m => m Bool
Returns true if there were any warnings.
data SourceError
A source error is an error that is caused by one or more errors in the
source code. A SourceError
is thrown by many functions in the
compilation pipeline. Inside GHC these errors are merely printed via
log_action
, but API clients may treat them differently, for example,
insert them into a list box. If you want the default behaviour, use the
idiom:
handleSourceError printExceptionAndWarnings $ do ... api calls that may fail ...
The SourceError
s error messages can be accessed via srcErrorMessages
.
This list may be empty if the compiler failed due to -Werror
(Opt_WarnIsError
).
See printExceptionAndWarnings
for more information on what to take care
of when writing a custom error handler.
Instances
mkSrcErr :: ErrorMessages -> SourceError
mkApiErr :: SDoc -> GhcApiError
throwOneError :: MonadIO m => ErrMsg -> m ab
Arguments
:: ExceptionMonad m | |
=> (SourceError -> m a) | exception handler |
-> m a | action to perform |
-> m a |
Perform the given action and call the exception handler if the action
throws a SourceError
. See SourceError
for more information.
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
handleFlagWarnings :: GhcMonad m => DynFlags -> [Located String] -> m ()
Sessions and compilation state
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) !(IORef WarningMessages) |
withSession :: GhcMonad m => (HscEnv -> m a) -> m a
Call the argument with the current session.
modifySession :: GhcMonad m => (HscEnv -> HscEnv) -> m ()
Set the current session to the result of applying the current session to the argument.
withTempSession :: GhcMonad m => (HscEnv -> HscEnv) -> m a -> m a
Call an action with a temporarily modified Session.
data HscEnv
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--. 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
|
hscEPS :: HscEnv -> IO ExternalPackageState
type FinderCache = ModuleNameEnv FindResult
The FinderCache
maps home module names to the result of
searching for that module. It records the results of searching for
modules along the search path. On :load
, we flush the entire
contents of this cache.
Although the FinderCache
range is FindResult
for convenience ,
in fact it will only ever contain Found
or NotFound
entries.
data FindResult
The result of searching for an imported module.
Constructors
Found ModLocation Module | The module was found |
NoPackage PackageId | The requested package was not found |
FoundMultiple [PackageId] | _Error_: both in multiple packages |
NotFound [FilePath] (Maybe PackageId) [PackageId] [PackageId] | The module was not found, including either * the specified places were searched * the package that this module should have been in * list of packages in which the module was hidden, * list of hidden packages containing this module |
NotFoundInPackage PackageId | The module was not found in this package |
type ModLocationCache = ModuleEnv ModLocation
Cache that remembers where we found a particular module. Contains both
home modules and package modules. On :load
, only home modules are
purged from this cache.
data Target
A compilation target.
A target may be supplied with the actual text of the module. If so, use this instead of the file contents (this is for use in an IDE where the file hasn't been saved by the user yet).
Constructors
Target | |
Fields
|
Instances
data TargetId
Constructors
TargetModule ModuleName | A module name: search for the file |
TargetFile FilePath (Maybe Phase) | A filename: preprocess & parse it to find the module name. If specified, the Phase indicates how to compile this file (which phase to start from). Nothing indicates the starting phase should be determined from the suffix of the filename. |
Instances
pprTargetId :: TargetId -> SDoc
type ModuleGraph = [ModSummary]
A ModuleGraph contains all the nodes from the home package (only). There will be a node for each source module, plus a node for each hi-boot module.
The graph is not necessarily stored in topologically-sorted order. Use
GHC.topSortModuleGraph
and Digraph.flattenSCC
to achieve this.
Callbacks
data GhcApiCallbacks
These functions are called in various places of the GHC API.
API clients can override any of these callbacks to change GHC's default behaviour.
Constructors
GhcApiCallbacks | |
Fields
|
withLocalCallbacks :: GhcMonad m => (GhcApiCallbacks -> GhcApiCallbacks) -> m a -> m a
Temporarily modify the callbacks. After the action is executed all callbacks are reset (not, however, any other modifications to the session state.)
Information about modules
data ModDetails
The ModDetails
is essentially a cache for information in the ModIface
for home modules only. Information relating to packages will be loaded into
global environments in ExternalPackageState
.
Constructors
ModDetails | |
Fields
|
data ModGuts
A ModGuts is carried through the compiler, accumulating stuff as it goes
There is only one ModGuts at any time, the one for the module
being compiled right now. Once it is compiled, a ModIface
and
ModDetails
are extracted and the ModGuts is dicarded.
Constructors
ModGuts | |
Fields
|
data CoreModule
A CoreModule consists of just the fields of a ModGuts
that are needed for
the GHC.compileToCoreModule
interface.
Constructors
CoreModule | |
Instances
data CgGuts
A restricted form of ModGuts
for code generation purposes
Constructors
CgGuts | |
Fields
|
data ForeignStubs
Foreign export stubs
Constructors
NoStubs | We don't have any stubs |
ForeignStubs SDoc SDoc | There are some stubs. Parameters: 1) Header file prototypes for foreign exported functions 2) C stubs to use when calling foreign exported functions |
type ImportedMods = ModuleEnv [(ModuleName, Bool, SrcSpan)]
Records the modules directly imported by a module for extracting e.g. usage information
data ModSummary
A single node in a 'ModuleGraph. The nodes of the module graph are one of:
- A regular Haskell source module
- A hi-boot source module
- An external-core source module
Constructors
ModSummary | |
Fields
|
Instances
ms_mod_name :: ModSummary -> ModuleName
showModMsg :: HscTarget -> Bool -> ModSummary -> String
isBootSummary :: ModSummary -> Bool
Did this ModSummary
originate from a hs-boot file?
msHsFilePath :: ModSummary -> FilePath
msHiFilePath :: ModSummary -> FilePath
msObjFilePath :: ModSummary -> FilePath
Information about the module being compiled
data HscSource
Constructors
HsSrcFile | |
HsBootFile | |
ExtCoreFile |
hscSourceString :: HscSource -> String
State relating to modules in this package
type HomePackageTable = ModuleNameEnv HomeModInfo
Helps us find information about modules in the home package
data HomeModInfo
Information about modules in the package being compiled
Constructors
HomeModInfo | |
Fields
|
hptInstances :: HscEnv -> (ModuleName -> Bool) -> ([Instance], [FamInst])
Find all the instance declarations (of classes and families) that are in
modules imported by this one, directly or indirectly, and are in the Home
Package Table. This ensures that we don't see instances from modules --make
compiled before this one, but which are not below this one.
hptRules :: HscEnv -> [(ModuleName, IsBootInterface)] -> [CoreRule]
Get rules from modules "below" this one (in the dependency sense)
hptVectInfo :: HscEnv -> VectInfo
Get the combined VectInfo of all modules in the home package table. In contrast to instances and rules, we don't care whether the modules are "below" us in the dependency sense. The VectInfo of those modules not "below" us does not affect the compilation of the current module.
State relating to known packages
data ExternalPackageState
Information about other packages that we have slurped in by reading their interface files
Constructors
EPS | |
Fields
|
data EpsStats
Accumulated statistics about what we are putting into the ExternalPackageState
.
"In" means stuff that is just read from interface files,
"Out" means actually sucked in and type-checked
Constructors
EpsStats | |
Fields
|
type PackageTypeEnv = TypeEnv
type PackageIfaceTable = ModuleEnv ModIface
Helps us find information about modules in the imported packages
lookupIfaceByModule :: DynFlags -> HomePackageTable -> PackageIfaceTable -> Module -> Maybe ModIface
emptyModIface :: Module -> ModIface
type PackageInstEnv = InstEnv
type PackageRuleBase = RuleBase
Annotations
prepareAnnotations :: HscEnv -> Maybe ModGuts -> IO AnnEnv
Deal with gathering annotations in from all possible places
and combining them into a single AnnEnv
Interactive context
data InteractiveContext
Interactive context, recording information relevant to GHCi
Constructors
InteractiveContext | |
Fields
|
mkPrintUnqualified :: DynFlags -> GlobalRdrEnv -> PrintUnqualified
Creates some functions that work out the best ways to format names for the user according to a set of heuristics
pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc
Interfaces
data ModIface
A ModIface
plus a ModDetails
summarises everything we know
about a compiled module. The ModIface
is the stuff *before* linking,
and can be written out to an interface file. The 'ModDetails is after
linking and can be completely recovered from just the ModIface
.
When we read an interface file, we also construct a ModIface
from it,
except that we explicitly make the mi_decls
and a few other fields empty;
as when reading we consolidate the declarations etc. into a number of indexed
maps and environments in the ExternalPackageState
.
Constructors
ModIface | |
Fields
|
mkIfaceWarnCache :: Warnings -> Name -> Maybe WarningTxt
Constructs the cache for the mi_warn_fn
field of a ModIface
mkIfaceHashCache :: [(Fingerprint, IfaceDecl)] -> OccName -> Maybe (OccName, Fingerprint)
Constructs cache for the mi_hash_fn
field of a ModIface
mkIfaceFixCache :: [(OccName, Fixity)] -> OccName -> Fixity
Fixity
data FixItem
Fixity information for an Name
. We keep the OccName in the range
so that we can generate an interface from it
Instances
lookupFixity :: FixityEnv -> Name -> Fixity
TyThings and type environments
tyThingClass :: TyThing -> Class
tyThingTyCon :: TyThing -> TyCon
tyThingDataCon :: TyThing -> DataCon
implicitTyThings :: TyThing -> [TyThing]
isImplicitTyThing :: TyThing -> Bool
Returns True
if there should be no interface-file declaration
for this thing on its own: either it is built-in, or it is part
of some other declaration, or it is generated implicitly by some
other declaration.
lookupType :: DynFlags -> HomePackageTable -> PackageTypeEnv -> Name -> Maybe TyThing
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
lookupTypeHscEnv :: HscEnv -> Name -> IO (Maybe TyThing)
As lookupType
, but with a marginally easier-to-use interface
if you have a HscEnv
extendTypeEnv :: TypeEnv -> TyThing -> TypeEnv
extendTypeEnvList :: TypeEnv -> [TyThing] -> TypeEnv
extendTypeEnvWithIds :: TypeEnv -> [Id] -> TypeEnv
lookupTypeEnv :: TypeEnv -> Name -> Maybe TyThing
typeEnvElts :: TypeEnv -> [TyThing]
typeEnvClasses :: TypeEnv -> [Class]
typeEnvTyCons :: TypeEnv -> [TyCon]
typeEnvIds :: TypeEnv -> [Id]
typeEnvDataCons :: TypeEnv -> [DataCon]
MonadThings
class Monad m => MonadThings m where
Class that abstracts out the common ability of the monads in GHC
to lookup a TyThing
in the monadic environment by Name
. Provides
a number of related convenience functions for accessing particular
kinds of TyThing
Methods
lookupThing :: Name -> m TyThing
lookupDataCon :: Name -> m DataCon
lookupTyCon :: Name -> m TyCon
lookupClass :: Name -> m Class
Instances
MonadThings CoreM | |
MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) | |
MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) |
Information on imports and exports
type WhetherHasOrphans = Bool
Records whether a module has orphans. An "orphan" is one of:
- An instance declaration in a module other than the definition module for one of the type constructors or classes in the instance head
- A transformation rule in a module other than the one defining the function in the head of the rule
type IsBootInterface = Bool
Did this module originate from a *-boot file?
data Usage
Records modules that we depend on by making a direct import from
Constructors
UsagePackageModule | Module from another package |
Fields
| |
UsageHomeModule | Module from the current package |
Fields
|
data Dependencies
Dependency information about modules and packages below this one in the import hierarchy.
Invariant: the dependencies of a module M
never includes M
.
Invariant: none of the lists contain duplicates.
Constructors
Deps | |
Fields
|
Instances
data NameCache
The NameCache makes sure that there is just one Unique assigned for each original name; i.e. (module-name, occ-name) pair and provides something of a lookup mechanism for those names.
Constructors
NameCache | |
Fields
|
availsToNameSet :: [AvailInfo] -> NameSet
availsToNameEnv :: [AvailInfo] -> NameEnv AvailInfo
availName :: GenAvailInfo name -> name
Just the main name made available, i.e. not the available pieces
of type or class brought into scope by the GenAvailInfo
availNames :: GenAvailInfo name -> [name]
All names made available by the availability information
data GenAvailInfo name
Records what things are available, i.e. in scope
Constructors
Avail name | An ordinary identifier in scope |
AvailTC name [name] | A type or class in scope. Parameters: 1) The name of the type or class 2) The available pieces of type or class.
NB: If the type or class is itself
to be in scope, it must be in this list.
Thus, typically: |
Instances
Eq name => Eq (GenAvailInfo name) | |
Outputable n => Outputable (GenAvailInfo n) | |
Binary name => Binary (GenAvailInfo name) |
type AvailInfo = GenAvailInfo Name
Name
d things that are available
type RdrAvailInfo = GenAvailInfo OccName
RdrName
d things that are available
type IfaceExport = (Module, [GenAvailInfo OccName])
The original names declared of a certain module that are exported
Warnings
data Warnings
Warning information for a module
Constructors
NoWarnings | Nothing deprecated |
WarnAll WarningTxt | Whole module deprecated |
WarnSome [(OccName, WarningTxt)] | Some specific things deprecated |
data WarningTxt
Constructors
WarningTxt [FastString] | |
DeprecatedTxt [FastString] |
Linker stuff
data Linkable
Information we can use to dynamically link modules into the compiler
Constructors
LM | |
Fields
|
Instances
isObjectLinkable :: Linkable -> Bool
data Unlinked
Objects which have yet to be linked by the compiler
Constructors
DotO FilePath | An object file (.o) |
DotA FilePath | Static archive file (.a) |
DotDLL FilePath | Dynamically linked library file (.so, .dll, .dylib) |
BCOs CompiledByteCode ModBreaks | A byte-code object, lives only in memory |
Instances
data CompiledByteCode
nameOfObject :: Unlinked -> FilePath
Retrieve the filename of the linkable if possible. Panic if it is a byte-code object
isInterpretable :: Unlinked -> Bool
Is this a bytecode linkable with no file on disk?
byteCodeOfObject :: Unlinked -> CompiledByteCode
Retrieve the compiled byte-code if possible. Panic if it is a file-based linkable
Program coverage
data HpcInfo
Information about a modules use of Haskell Program Coverage
Constructors
HpcInfo | |
Fields
| |
NoHpcInfo | |
Fields
|
emptyHpcInfo :: AnyHpcUsage -> HpcInfo
isHpcUsed :: HpcInfo -> AnyHpcUsage
Find out if HPC is used by this module or any of the modules it depends upon
type AnyHpcUsage = Bool
This is used to signal if one of my imports used HPC instrumentation even if there is no module-local HPC usage
Breakpoints
data ModBreaks
All the information about the breakpoints for a given module
Constructors
ModBreaks | |
Fields
|
type BreakIndex = Int
Breakpoint index
Vectorisation information
data VectInfo
Vectorisation information for ModGuts
, ModDetails
and ExternalPackageState
.
Constructors
VectInfo | |
Fields
|
data IfaceVectInfo
Vectorisation information for ModIface
: a slightly less low-level view
Constructors
IfaceVectInfo | |
Fields
|
Instances
plusVectInfo :: VectInfo -> VectInfo -> VectInfo