HORIZON HASKELLDocslts/ghc-10.0.xaa25b892026-10-10Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · aa25b89 · 2026-10-10

Moduleghc-10.0.0.20260917GHC2024

GHC.Unit.Home.Graph

A HomeUnitGraph (HUG) collects information about all the home units. Crucially, each node in a HomeUnitGraph includes a HomePackageTable.

Often, we don't want to query just a single HomePackageTable, but rather all HomePackageTables of all home units.

This module is responsible for maintaining this bridge between querying all home units vs querying the home package table directly. Think lookupHug vs lookupHpt, hugAllInstances vs hptAllInstances, where the hug version replies with information from all home units, and the hpt version with information pertaining to a single home unit.

Meant to be imported qualified as HUG. Example usage:

import GHC.Unit.Home.Graph (HomeUnitGraph, HomeUnitEnv)
import qualified GHC.Unit.Home.Graph as HUG
usage = ... HUG.insertHug hug uid modname modinfo ...
  • 3 types
  • 32 values
datadata HomeUnitEnv
#

Constructors

  • HomeUnitEnv
    • homeUnitEnv_units :: !UnitState

      External units

    • homeUnitEnv_dflags :: DynFlags

      The dynamic flag settings

    • homeUnitEnv_hpt :: HomePackageTable

      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.)

    • homeUnitEnv_home_unit :: !Maybe HomeUnit

      Home-unit

Operations

5 declarations
valuerestrictHug :: [(UnitId, [HomeModInfo])] -> HomeUnitGraph -> IO ()
#

Thin each HPT variable to only contain keys from the given dependencies. This is used at the end of upsweep to make sure that only completely successfully loaded modules are visible for subsequent operations.

Lookups

Reachability

Very important queries

4 declarations

Find all the instance declarations (of classes and families) from the Home Package Table filtered by the provided predicate function. Used in tcRnImports, to select the instances that are in the transitive closure of imports from the currently compiled module.

Utilities

2 declarations

Printing

Auxiliary internal structure

11 declarations