ghc-9.2.1: The GHC API

GHC.Unit.Module.ModIface

Synopsis

# Documentation

type ModIface = ModIface_ 'ModIfaceFinal Source #

data ModIface_ (phase :: ModIfacePhase) Source #

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 Fieldsmi_module :: !ModuleName of the module we are formi_sig_of :: !(Maybe Module)Are we a sig of another mod?mi_hsc_src :: !HscSourceBoot? Signature?mi_deps :: DependenciesThe dependencies of the module. This is consulted for directly-imported modules, but not for anything else (hence lazy)mi_usages :: [Usage]Usages; kept sorted so that it's easy to decide whether to write a new iface file (changing usages doesn't affect the hash of this module) NOT STRICT! we read this field lazily from the interface file It is *only* consulted by the recompilation checkermi_exports :: ![IfaceExport]Exports Kept sorted by (mod,occ), to make version comparisons easier Records the modules that are the declaration points for things exported by this module, and the OccNames of those thingsmi_used_th :: !BoolModule required TH splices when it was compiled. This disables recompilation avoidance (see #481).mi_fixities :: [(OccName, Fixity)]Fixities NOT STRICT! we read this field lazily from the interface filemi_warns :: WarningsWarnings NOT STRICT! we read this field lazily from the interface filemi_anns :: [IfaceAnnotation]Annotations NOT STRICT! we read this field lazily from the interface filemi_decls :: [IfaceDeclExts phase]Type, class and variable declarations The hash of an Id changes if its fixity or deprecations change (as well as its type of course) Ditto data constructors, class operations, except that the hash of the parent class/tycon changesmi_globals :: !(Maybe GlobalRdrEnv)Binds all the things defined at the top level in the original source code for this module. which is NOT the same as mi_exports, nor mi_decls (which may contains declarations for things not actually defined by the user). Used for GHCi and for inspecting the contents of modules via the GHC API only.(We need the source file to figure out the top-level environment, if we didn't compile this module from source then this field contains Nothing).Strictly speaking this field should live in the HomeModInfo, but that leads to more plumbing.mi_insts :: [IfaceClsInst]Sorted class instancemi_fam_insts :: [IfaceFamInst]Sorted family instancesmi_rules :: [IfaceRule]Sorted rulesmi_hpc :: !AnyHpcUsageTrue if this program uses Hpc at any point in the program.mi_trust :: !IfaceTrustInfoSafe Haskell Trust information for this module.mi_trust_pkg :: !BoolDo we require the package this module resides in be trusted to trust this module? This is used for the situation where a module is Safe (so doesn't require the package be trusted itself) but imports some trustworthy modules from its own package (which does require its own package be trusted). See Note [Trust Own Package] in GHC.Rename.Namesmi_complete_matches :: [IfaceCompleteMatch] mi_doc_hdr :: Maybe HsDocStringModule header.mi_decl_docs :: DeclDocMapDocs on declarations.mi_arg_docs :: ArgDocMapDocs on arguments.mi_final_exts :: !(IfaceBackendExts phase)Either () or ModIfaceBackend for a fully instantiated interface.mi_ext_fields :: ExtensibleFieldsAdditional optional fields, where the Map key represents the field name, resulting in a (size, serialized data) pair. Because the data is intended to be serialized through the internal Binary class (increasing compatibility with types using Name and FastString, such as HIE), this format is chosen over ByteStrings.

#### Instances

Instances details
 Source # Instance detailsDefined in GHC.Unit.Module.ModIface Methodsput_ :: BinHandle -> ModIface -> IO () Source # (NFData (IfaceBackendExts phase), NFData (IfaceDeclExts phase)) => NFData (ModIface_ phase) Source # Instance detailsDefined in GHC.Unit.Module.ModIface Methodsrnf :: ModIface_ phase -> () Source #

type PartialModIface = ModIface_ 'ModIfaceCore Source #

Extends a PartialModIface with information which is either: * Computed after codegen * Or computed just before writing the iface to disk. (Hashes) In order to fully instantiate it.

Constructors

 ModIfaceBackend Fieldsmi_iface_hash :: !FingerprintHash of the whole interfacemi_mod_hash :: !FingerprintHash of the ABI onlymi_flag_hash :: !FingerprintHash of the important flags used when compiling the module, excluding optimisation flagsmi_opt_hash :: !FingerprintHash of optimisation flagsmi_hpc_hash :: !FingerprintHash of hpc flagsmi_plugin_hash :: !FingerprintHash of pluginsmi_orphan :: !WhetherHasOrphansWhether this module has orphansmi_finsts :: !WhetherHasFamInstWhether this module has family instances. See Note [The type family instance consistency story].mi_exp_hash :: !FingerprintHash of export listmi_orphan_hash :: !FingerprintHash for orphan rules, class and family instances combinedmi_warn_fn :: !(OccName -> Maybe WarningTxt)Cached lookup for mi_warnsmi_fix_fn :: !(OccName -> Maybe Fixity)Cached lookup for mi_fixitiesmi_hash_fn :: !(OccName -> Maybe (OccName, Fingerprint))Cached lookup for mi_decls. The Nothing in mi_hash_fn means that the thing isn't in decls. It's useful to know that when seeing if we are up to date wrt. the old interface. The OccName is the parent of the name, if it has one.

type family IfaceDeclExts (phase :: ModIfacePhase) where ... Source #

Selects a IfaceDecl representation. For fully instantiated interfaces we also maintain a fingerprint, which is used for recompilation checks.

Equations

 IfaceDeclExts 'ModIfaceCore = IfaceDecl IfaceDeclExts 'ModIfaceFinal = (Fingerprint, IfaceDecl)

type family IfaceBackendExts (phase :: ModIfacePhase) where ... Source #

Equations

 IfaceBackendExts 'ModIfaceCore = () IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend

The original names declared of a certain module that are exported

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 rewrite rule in a module other than the one defining the function in the head of the rule

Does this module define family instances?

Old-style accessor for whether or not the ModIface came from an hs-boot file.

Lookups up a (possibly cached) fixity from a ModIface_. If one cannot be found, defaultFixity is returned instead.

The semantic module for this interface; e.g., if it's a interface for a signature, if mi_module is p[A=A]:A, mi_semantic_module will be A.

The "precise" free holes, e.g., the signatures that this ModIface_ depends on.

Given a set of free holes, and a unit identifier, rename the free holes according to the instantiation of the unit identifier. For example, if we have A and B free, and our unit identity is p[A=C,B=impl:B], the renamed free holes are just C.

Constructs cache for the mi_hash_fn field of a ModIface_