HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.Types.Var

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

  • Id: see GHC.Types.Id#name_types

  • Var is a synonym for the Id type but it may additionally potentially contain type variables, which have a Kind rather than a Type and only contain some extra details during typechecking.

These Var names may either be global or local, see GHC.Types.Var#globalvslocal

Global Ids and Vars are those that are imported or correspond to a data constructor, primitive operation, or record selectors. Local Ids and Vars are those bound within an expression (e.g. by a lambda) or at the top level of the module being compiled.

  • 39 types
  • 92 values
  • Packageghc-9.10.3
  • Exports133
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceVar.hs

The main data type and synonyms

17 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 CoVar = Id
#

Coercion Variable

typetype Id = Var
#

Identifier

typetype DFunId = Id
#

Dictionary Function Identifier

typetype EvId = Id
#

Evidence Identifier

typetype IpId = EvId
#

Implicit parameter Identifier

typetype TyVar = Var
#

Type or kind Variable

typetype TcTyVar = Var
#

Type variable that might be a metavariable

typetype TKVar = Var
#

Type or Kind Variable

typetype TyCoVar = Id
#

Type or Coercion Variable

In and Out variants

8 declarations

Taking Vars apart

Modifying Vars

valueupdateVarType :: (Type -> Type) -> Var -> Var
#

Update a Vars type. Does not update the multiplicity stored in an Id, if any. Because of the possibility for abuse, ASSERTs that there is no multiplicity to update.

valueupdateVarTypeM :: Monad m => (Type -> m Type) -> Var -> m Var
#

Update a Vars type monadically. Does not update the multiplicity stored in an Id, if any. Because of the possibility for abuse, ASSERTs that there is no multiplicity to update.

Constructing, taking apart, modifying Ids

valuesetIdExported :: Id -> Id
#

Exports the given local Id. Can also be called on global Ids, such as data constructors and class operations, which are born as global Ids and automatically exported

Predicates

valueisId :: Var -> Bool
#

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

valueisTyVar :: Var -> Bool
#

Is this a type-level (i.e., computationally irrelevant, thus erasable) variable? Satisfies isTyVar = not . isId.

valueisLocalVar :: Var -> Bool
#

isLocalVar returns True for type variables as well as local Ids These are the variables that we need to pay attention to when finding free variables, or doing dependency analysis.

mustHaveLocalBinding returns True of Ids and TyVars that must have a binding in this module. The converse is not quite right: there are some global Ids that must have bindings, such as record selectors. But that doesn't matter, because it's only used for assertions

ForAllTyFlags

9 declarations
datadata ForAllTyFlag
#

ForAllTyFlag

Is something required to appear in source Haskell (Required), permitted by request (Specified) (visible type application), or prohibited entirely from appearing in source Haskell (Inferred)? See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep

Instances7Eq, Data, Ord, NFData, Binary, Outputable, …
datadata Specificity
#

Whether an Invisible argument may appear in source Haskell.

Constructors

  • InferredSpec

    the argument may not appear in source Haskell, it is only inferred.

  • SpecifiedSpec

    the argument may appear in source Haskell, but isn't required.

Instances10Eq, Data, Ord, NFData, Binary, OutputableBndrFlag, …

The ForAllTyFlag on a (Lam a e) term, where a is a type variable. If you want other ForAllTyFlag, use a cast. See Note [Required foralls in Core] in GHC.Core.TyCo.Rep

FunTyFlag

14 declarations
datadata FunTyFlag
#

The non-dependent version of ForAllTyFlag. See Note [FunTyFlag] Appears here partly so that it's together with its friends ForAllTyFlag and ForallVisFlag, but also because it is used in IfaceType, rather early in the compilation chain

Instances5Eq, Data, Ord, Outputable, Binary

PiTyBinder

10 declarations
valueisTyBinder :: PiTyBinder -> Bool
#

If its a named binder, is the binder a tyvar? Returns True for nondependent binder. This check that we're really returning a *Ty*Binder (as opposed to a coercion binder). That way, if/when we allow coercion quantification in more places, we'll know we missed updating some function.

TyVar's

25 declarations
datadata VarBndr var argf
#

Constructors

Instances6Data, NamedThing, Outputable, Binary

ExportFlag

Constructing TyVar's

Taking TyVars apart

Modifying TyVars

valuenonDetCmpVar :: Var -> Var -> Ordering
#

Compare Vars by their Uniques. This is what Ord Var does, provided here to make it explicit at the call-site that it can introduce non-determinism. See Note [Unique Determinism]