HORIZON HASKELLDocslts/ghc-9.14.xb2f3bfd2026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

Moduleghc-lib-parser-9.14.1.20251220GHC2021

GHC.Unit.Types

Unit & Module types

This module is used to resolve the loops between Unit and Module types (Module references a Unit and vice-versa).

  • 19 types
  • 1 class
  • 38 values

Modules

10 declarations
datadata GenModule unit
#

A generic module is a pair of a unit identifier and a ModuleName.

Constructors

Instances10Functor, Uniquable, Outputable, Eq, Data, Ord, …

Calculate the free holes of a Module. If this set is non-empty, this module was defined in an indefinite library that had required signatures.

If a module has free holes, that means that substitutions can operate on it; if it has no free holes, substituting over a module has no effect.

Units

26 declarations
classclass IsUnitId u where
#

Class for types that are used as unit identifiers (UnitKey, UnitId, Unit)

We need this class because we create new unit ids for virtual units (see VirtUnit) and they have to to be made from units with different kinds of identifiers.

Instances4IsUnitId
datadata GenUnit uid
#

A unit identifier identifies a (possibly partially) instantiated library. It is primarily used as part of Module, which in turn is used in Name, which is used to give names to entities when typechecking.

There are two possible forms for a Unit:

1) It can be a RealUnit, in which case we just have a DefUnitId that uniquely identifies some fully compiled, installed library we have on disk.

2) It can be an VirtUnit. When we are typechecking a library with missing holes, we may need to instantiate a library on the fly (in which case we don't have any on-disk representation.) In that case, you have an InstantiatedUnit, which explicitly records the instantiation, so that we can substitute over it.

Constructors

  • RealUnit !(Definite uid)

    Installed definite unit (either a fully instantiated unit or a closed unit)

  • VirtUnit !(GenInstantiatedUnit uid)

    Virtual unit instantiated on-the-fly. It may be definite if all the holes are instantiated but we don't have code objects for it.

  • HoleUnit

    Fake hole unit

Instances11Data, Ord, Show, NFData, Outputable, Binary, …
  • Data UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Ord UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Show UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • NFData UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Uniquable ModuleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable ModuleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Binary UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • IsUnitId u => Eq (GenUnit u)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • IsUnitId u => Uniquable (GenUnit u)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • IsUnitId u => IsUnitId (GenUnit u)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
newtypenewtype UnitId
#

A UnitId identifies a built library in a database and is used to generate unique symbols, etc. It's usually of the form:

pkgname-1.2:libname+hash

These UnitId are provided to us via the -this-unit-id flag.

The library in question may be definite or indefinite; if it is indefinite, none of the holes have been filled (we never install partially instantiated libraries as we can cheaply instantiate them on-the-fly, cf VirtUnit). Put another way, an installed unit id is either fully instantiated, or not instantiated at all.

Constructors

Instances20Eq, Data, Ord, Show, NFData, Uniquable, …
  • Eq UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Data UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Data UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Ord UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Ord UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Show UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • NFData UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • NFData UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Uniquable ModuleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Uniquable UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable InstalledModuleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable InstantiatedModuleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable InstantiatedUnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable ModuleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Outputable UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Binary InstantiatedUnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Binary UnitDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • Binary UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
  • IsUnitId UnitIdDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Unit.Types
datadata GenInstantiatedUnit unit
#

An instantiated unit.

It identifies an indefinite library (with holes) that has been instantiated.

This unit may be indefinite or not (i.e. with remaining holes or not). If it is definite, we don't know if it has already been compiled and installed in a database. Nevertheless, we have a mechanism called "improvement" to try to match a fully instantiated unit with existing compiled and installed units: see Note [VirtUnit to RealUnit improvement].

An indefinite unit identifier pretty-prints to something like p[H=H,A=aimpl:A>] (p is the UnitId, and the brackets enclose the module substitution).

Constructors

Instances5Outputable, Binary, Eq, Ord

Generate a uniquely identifying hash (internal unit-id) for an instantiated unit.

This is a one-way function. If the indefinite unit has not been instantiated at all, we return its unit-id.

This hash is completely internal to GHC and is not used for symbol names or file paths. It is different from the hash Cabal would produce for the same instantiated unit.

valuefsToUnit :: FastString -> Unit
#

Create a new simple unit identifier from a FastString. Internally, this is primarily used to specify wired-in unit identifiers.

valuetoUnitId :: Unit -> UnitId
#

Return the UnitId of the Unit. For on-the-fly instantiated units, return the UnitId of the indefinite unit this unit is an instance of.

Unit Ids

2 declarations

Utils

1 declaration
newtypenewtype Definite unit
#

A definite unit (i.e. without any free module hole)

Constructors

Instances7Functor, Eq, Ord, Uniquable, Outputable, Binary, …

Wired-in units

16 declarations
valuemainUnitId :: UnitId
#

This is the package Id for the current program. It is the default package Id if you don't specify a package name. We don't add this prefix to symbol names, since there can be only one main package per program.

Boot modules

4 declarations
datadata IsBootInterface
#

Indicates whether a module name is referring to a boot interface (hs-boot file) or regular module (hs file). We need to treat boot modules specially when building compilation graphs, since they break cycles. Regular source files and signature files are treated equivalently.

Instances6Eq, Data, Ord, Show, NFData, Binary
  • Eq IsBootInterfaceDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.ImpExp.IsBoot
  • Data IsBootInterfaceDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.ImpExp.IsBoot
  • Ord IsBootInterfaceDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.ImpExp.IsBoot
  • Show IsBootInterfaceDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.ImpExp.IsBoot
  • NFData IsBootInterfaceDefined in ghc-lib-parser-9.14.1.20251220 · Language.Haskell.Syntax.ImpExp.IsBoot
  • Binary IsBootInterfaceDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Utils.Binary
datadata GenWithIsBoot mod
#

This data type just pairs a value mod with an IsBootInterface flag. In practice, mod is usually a Module or ModuleName'.

Instances9Functor, Foldable, Traversable, Eq, Ord, Show, …