A UnitEnv provides the complete interface into everything that is loaded
into a GHC session, including the HomeUnitGraph for mapping home units to their
HomePackageTables (which store information about all home modules), and
the ExternalPackageState which provides access to all external packages
loaded.
This module is meant to be imported as UnitEnv when calling insertHpt:
import GHC.Unit.Env (UnitEnv, HomeUnitGraph, HomeUnitEnv)
import GHC.Unit.Env as UnitEnv
Here is an overview of how the UnitEnv, ModuleGraph, HUG, HPT, and EPS interact:
The home package table describes already-compiled
home-package modules, excluding the module we
are compiling right now.
(In one-shot mode the current module is the only
home-package module, so homeUnitEnv_hpt is empty. All other
modules count as "external-package" modules.
However, even in GHCi mode, hi-boot interfaces are
demand-loaded into the external-package table.)
homeUnitEnv_hpt is not mutable because we only demand-load
external packages; the home package is eagerly
loaded, module by module, by the compilation manager.
The HPT may contain modules compiled earlier by --make
but not actually below the current module in the dependency
graph.
(This changes a previous invariant: changed Jan 05.)
Lookup UnitInfo for every preload unit from the UnitState, for every unit
used to instantiate the home unit, and for every unit explicitly passed in
the given list of UnitId.
renameUnitId oldUnit newUnit UnitEnv, it is assumed that the oldUnit exists in the home units map,
otherwise we panic.
The DynFlags associated with the home unit will have its field homeUnitId set to newUnit.