The UnitState contains a plethora of information local to a single HomeUnitEnv.
It stores module visibilities, unit trust for SafeHaskell, available units for error messages,
explicit unit dependencies and knows how to instantiate backpack signature and holes
on demand.
A HomeUnitEnv should rarely/never have to look into the UnitIndex, all external
unit related information is stored in the UnitState.
Constructors
UnitStateunitInfoMap :: UnitInfoMapA mapping of Unit to UnitInfo. This list is adjusted so that only valid units are here. UnitInfo reflects what was stored *on disk*, except for the
trustedflag, which is adjusted at runtime. (In particular, some units in this map may have theexposedflag be False.)All values are shared with UnitIndex.globalUnits. See Note [Sharing UnitInfos across the
UnitEnv] for details.trustedUnits :: !TrustOverlaypackageNameMap :: UniqFM PackageName UnitIdA mapping of PackageName to UnitId. If several units have the same package name (e.g. different instantiations), then we return one of them... This is used when users refer to packages in Backpack includes. And also to resolve package qualifiers with the PackageImports extension.
preloadUnits :: [UnitId]The units we're going to link in eagerly. This list should be in reverse dependency order; that is, a unit is always mentioned before the units it depends on.
explicitUnits :: [(Unit, Maybe PackageArg)]Units which we explicitly depend on (from a command line flag). We'll use this to generate version macros and the unused packages warning. The original flag which was used to bring the unit into scope is recorded for the -Wunused-packages warning.
homeUnitDepends :: Set UnitIdmoduleNameProvidersMap :: !ModuleNameProvidersMapThis is a full map from ModuleName to all modules which may possibly be providing it. These providers may be hidden (but we'll still want to report them in error messages), or it may be an ambiguous import.
pluginModuleNameProvidersMap :: !ModuleNameProvidersMapA map, like moduleNameProvidersMap, but controlling plugin visibility.
requirementContext :: UniqMap ModuleName [InstantiatedModule]A map saying, for each requirement, what interfaces must be merged together when we use them. For example, if our dependencies are
p[A=<A>]andq[A=<A>,B=r[C=<A>]:B], then the interfaces to merge for A arep[A=<A>]:A,q[A=<A>,B=r[C=<A>]:B]:Aandr[C=<A>]:C.There's an entry in this map for each hole in our home library.
allowVirtualUnits :: !BoolIndicate if we can instantiate units on-the-fly.
This should only be true when we are type-checking an indefinite unit. See Note [About units] in GHC.Unit.