HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

GHC.Types.Id

GHC uses several kinds of name internally:

  • OccName: see GHC.Types.Name.Occurrence#name_types

  • RdrName: see GHC.Types.Name.Reader#name_types

  • Name: see GHC.Types.Name#name_types

  • GHC.Types.Id.Id represents names that not only have a Name but also a Type and some additional details (a IdInfo and one of LocalIdDetails or GlobalIdDetails) that are added, modified and inspected by various compiler passes. These Var names may either be global or local, see GHC.Types.Var#globalvslocal

  • Var: see GHC.Types.Var#name_types

  • 9 types
  • 139 values
  • Packageghc-9.10.3
  • Exports148
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceId.hs

The main types

3 declarations
datadata Var
#

Variable

Essentially a typed Name, that may also contain some additional information about the Var and its use sites.

Instances15Data, Ord, NamedThing, Outputable, Uniquable, HasOccName, …
typetype Id = Var
#

Identifier

valueisId :: Var -> Bool
#

Is this a value-level (i.e., computationally relevant) Identifier? Satisfies isId = not . isTyVar.

In and Out variants

4 declarations

Simple construction

valuemkExportedLocalId :: IdDetails -> Name -> Type -> Id
#

Create a local Id that is marked as exported. This prevents things attached to it from being removed as dead code. See Note [Exported LocalIds]

valuemkTemplateLocal :: Int -> Type -> Id
#

Create a template local: a family of system local Ids in bijection with Ints, typically used in unfoldings

Taking an Id apart

Modifying an Id

valuesetIdType :: Id -> Type -> Id
#

Not only does this set the Id Type, it also evaluates the type to try and reduce space usage

Predicates on Ids

valueisImplicitId :: Id -> Bool
#

isImplicitId tells whether an Ids info is implied by other declarations, so we don't need to put its signature in an interface file, even if it's mentioned in some other interface unfolding.

valueisStrictId :: Id -> Bool
#

isStrictId says whether either (a) the Id has a strict demand placed on it or (b) definitely has a "strict type", such that it can always be evaluated strictly (i.e an unlifted type) We need to check (b) as well as (a), because when the demand for the given id hasn't been computed yet but id has a strict type, we still want `isStrictId id` to be True. Returns False if the type is levity polymorphic; False is always safe.

valueidDataCon :: Id -> DataCon
#

Get from either the worker or the wrapper Id to the DataCon. Currently used only in the desugarer.

INVARIANT: idDataCon (dataConWrapId d) = d: remember, dataConWrapId can return either the wrapper or the worker

valueisWorkerLikeId :: Id -> Bool
#

An Id for which we might require all callers to pass strict arguments properly tagged + evaluated.

See Note [CBV Function Ids]

valuehasNoBinding :: Id -> Bool
#

Returns True of an Id which may not have a binding, even though it is defined in this module.

Join variables

Inline pragma stuff

One-shot lambdas

Reading IdInfo fields

valueidFunRepArity :: Id -> RepArity
#

This function counts all arguments post-unarisation, which includes arguments with no runtime representation -- see Note [Unarisation and arity]

Writing IdInfo fields

valuezapIdUnfolding :: Id -> Id
#

Similar to trimUnfolding, but also removes evaldness info.