HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleghc-lib-parser-9.14.1.20251220GHC2021

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.

Contents
  1. The main data type and synonyms
  2. In and Out variants
  3. Taking Vars apart
  4. Modifying Vars
  5. Constructing, taking apart, modifying Ids
  6. Predicates
  7. ForAllTyFlags
  8. FunTyFlag
  9. PiTyBinder
  10. TyVar's
  11. ExportFlag
  12. Constructing TyVar's
  13. Taking TyVars apart
  14. Modifying TyVars
Synopsis

The main data type and synonyms

datadata Var

Variable

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

Instances13Data, Ord, Uniquable, Outputable, NamedThing, HasOccName, …
  • Eq VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Data VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Ord VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Uniquable VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Outputable VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • NamedThing VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • OutputableBndr VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Core.Ppr · orphan
  • HasOccName VarDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Eq (DeBruijn CoreAlt)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Core.Map.Expr · orphan
  • Eq (DeBruijn CoreExpr)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Core.Map.Expr · orphan
  • Eq (DeBruijn Var)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Core.Map.Type
  • OutputableBndr (Id, TagSig)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Stg.EnforceEpt.TagSig
  • type Anno Id = SrcSpanAnnNDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Extension · orphan

In and Out variants

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

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

Instances8Eq, Data, Ord, NFData, Binary, OutputableBndrFlag, …
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.

Instances7Eq, 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

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

Instances6Eq, Data, Ord, NFData, Outputable, Binary
  • Eq FunTyFlagDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Data FunTyFlagDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Ord FunTyFlagDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • NFData FunTyFlagDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Outputable FunTyFlagDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var
  • Binary FunTyFlagDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Var

PiTyBinder

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

datadata VarBndr var argf
#

Constructors

Instances9Eq, Data, Ord, NFData, 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]