- mg_module :: !Module,
- mg_boot :: IsBootInterface, -- Whether it's an hs-boot module
- mg_exports :: ![AvailInfo], -- What it exports
- mg_deps :: !Dependencies, -- What is below it, directly or
- -- otherwise
- mg_dir_imps :: ![Module], -- Directly-imported modules; used to
- -- generate initialisation code
- mg_usages :: ![Usage], -- Version info for what it needed
-
- mg_rdr_env :: !GlobalRdrEnv, -- Top-level lexical environment
- mg_fix_env :: !FixityEnv, -- Fixity env, for things declared in
- -- this module
- mg_deprecs :: !Deprecations, -- Deprecations declared in the module
-
- mg_types :: !TypeEnv,
- mg_insts :: ![Instance], -- Instances
- mg_fam_insts :: ![FamInst], -- Instances
- mg_rules :: ![CoreRule], -- Rules from this module
- mg_binds :: ![CoreBind], -- Bindings for this module
- mg_foreign :: !ForeignStubs,
- mg_hpc_info :: !HpcInfo -- info about coverage tick boxes
+ mg_module :: !Module, -- ^ Module being compiled
+ mg_boot :: IsBootInterface, -- ^ Whether it's an hs-boot module
+ mg_exports :: ![AvailInfo], -- ^ What it exports
+ mg_deps :: !Dependencies, -- ^ What it depends on, directly or
+ -- otherwise
+ mg_dir_imps :: !ImportedMods, -- ^ Directly-imported modules; used to
+ -- generate initialisation code
+ mg_used_names:: !NameSet, -- ^ What the module needed (used in 'MkIface.mkIface')
+
+ mg_rdr_env :: !GlobalRdrEnv, -- ^ Top-level lexical environment
+
+ -- These fields all describe the things **declared in this module**
+ mg_fix_env :: !FixityEnv, -- ^ Fixities declared in this module
+ -- TODO: I'm unconvinced this is actually used anywhere
+ mg_types :: !TypeEnv, -- ^ Types declared in this module
+ mg_insts :: ![Instance], -- ^ Class instances declared in this module
+ mg_fam_insts :: ![FamInst], -- ^ Family instances declared in this module
+ mg_rules :: ![CoreRule], -- ^ Before the core pipeline starts, contains
+ -- rules declared in this module. After the core
+ -- pipeline starts, it is changed to contain all
+ -- known rules for those things imported
+ mg_binds :: ![CoreBind], -- ^ Bindings for this module
+ mg_foreign :: !ForeignStubs, -- ^ Foreign exports declared in this module
+ mg_warns :: !Warnings, -- ^ Warnings declared in the module
+ mg_hpc_info :: !HpcInfo, -- ^ Coverage tick boxes in the module
+ mg_modBreaks :: !ModBreaks, -- ^ Breakpoints for the module
+ mg_vect_info :: !VectInfo, -- ^ Pool of vectorised declarations in the module
+
+ -- The next two fields are unusual, because they give instance
+ -- environments for *all* modules in the home package, including
+ -- this module, rather than for *just* this module.
+ -- Reason: when looking up an instance we don't want to have to
+ -- look at each module in the home package in turn
+ mg_inst_env :: InstEnv,
+ -- ^ Class instance environment from /home-package/ modules (including
+ -- this one); c.f. 'tcg_inst_env'
+ mg_fam_inst_env :: FamInstEnv
+ -- ^ Type-family instance enviroment for /home-package/ modules
+ -- (including this one); c.f. 'tcg_fam_inst_env'
+ }
+
+-- The ModGuts takes on several slightly different forms:
+--
+-- After simplification, the following fields change slightly:
+-- mg_rules Orphan rules only (local ones now attached to binds)
+-- mg_binds With rules attached
+
+-- | A CoreModule consists of just the fields of a 'ModGuts' that are needed for
+-- the 'GHC.compileToCoreModule' interface.
+data CoreModule
+ = CoreModule {
+ -- | Module name
+ cm_module :: !Module,
+ -- | Type environment for types declared in this module
+ cm_types :: !TypeEnv,
+ -- | Declarations
+ cm_binds :: [CoreBind],
+ -- | Imports
+ cm_imports :: ![Module]