ghc-6.12.3: The GHC APISource codeContentsIndex
Var
Contents
The main data type
Taking Vars apart
Modifying Vars
Constructing, taking apart, modifying Ids
Predicates
Type variable data type
Constructing TyVars
Taking TyVars apart
Modifying TyVars
Coercion variable data type
Constructing CoVars
Taking CoVars apart
Modifying CoVars
Var type synonyms
Description

GHC uses several kinds of name internally:

  • OccName.OccName: see OccName
  • RdrName.RdrName: see RdrName
  • Name: see Name
  • Id.Id: see Id
  • Var is a synonym for the Id.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 Var

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.

Synopsis
data Var
varName :: Var -> Name
varUnique :: Var -> Unique
varType :: Var -> Kind
setVarName :: Var -> Name -> Var
setVarUnique :: Var -> Unique -> Var
setVarType :: Id -> Type -> Id
mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
mkLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
idInfo :: Id -> IdInfo
idDetails :: Id -> IdDetails
lazySetIdInfo :: Id -> IdInfo -> Var
setIdDetails :: Id -> IdDetails -> Id
globaliseId :: Id -> Id
setIdExported :: Id -> Id
setIdNotExported :: Id -> Id
isCoVar :: Var -> Bool
isId :: Var -> Bool
isTyVar :: Var -> Bool
isTcTyVar :: Var -> Bool
isLocalVar :: Var -> Bool
isLocalId :: Var -> Bool
isGlobalId :: Var -> Bool
isExportedId :: Var -> Bool
mustHaveLocalBinding :: Var -> Bool
type TyVar = Var
mkTyVar :: Name -> Kind -> TyVar
mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
mkWildCoVar :: Kind -> TyVar
tyVarName :: TyVar -> Name
tyVarKind :: TyVar -> Kind
tcTyVarDetails :: Var -> TcTyVarDetails
setTyVarName :: TyVar -> Name -> TyVar
setTyVarUnique :: TyVar -> Unique -> TyVar
setTyVarKind :: TyVar -> Kind -> TyVar
type CoVar = TyVar
mkCoVar :: Name -> Kind -> CoVar
coVarName :: CoVar -> Name
setCoVarUnique :: CoVar -> Unique -> CoVar
setCoVarName :: CoVar -> Name -> CoVar
type Id = Var
type DictId = Var
The main data type
data Var Source
Essentially a typed Name, that may also contain some additional information about the Var and it's use sites.
show/hide Instances
Taking Vars apart
varName :: Var -> NameSource
varUnique :: Var -> UniqueSource
varType :: Var -> KindSource
Modifying Vars
setVarName :: Var -> Name -> VarSource
setVarUnique :: Var -> Unique -> VarSource
setVarType :: Id -> Type -> IdSource
Constructing, taking apart, modifying Ids
mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> IdSource
mkLocalVar :: IdDetails -> Name -> Type -> IdInfo -> IdSource
mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> IdSource
Exported Vars will not be removed as dead code
idInfo :: Id -> IdInfoSource
idDetails :: Id -> IdDetailsSource
lazySetIdInfo :: Id -> IdInfo -> VarSource
setIdDetails :: Id -> IdDetails -> IdSource
globaliseId :: Id -> IdSource
If it's a local, make it global
setIdExported :: Id -> IdSource
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
setIdNotExported :: Id -> IdSource
We can only do this to LocalIds
Predicates
isCoVar :: Var -> BoolSource
isId :: Var -> BoolSource
isTyVar :: Var -> BoolSource
isTcTyVar :: Var -> BoolSource
isLocalVar :: Var -> BoolSource
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.
isLocalId :: Var -> BoolSource
isGlobalId :: Var -> BoolSource
isExportedId :: Var -> BoolSource
isExportedIdVar means "don't throw this away"
mustHaveLocalBinding :: Var -> BoolSource
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
Type variable data type
type TyVar = VarSource
Constructing TyVars
mkTyVar :: Name -> Kind -> TyVarSource
mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVarSource
mkWildCoVar :: Kind -> TyVarSource
Create a type variable that is never referred to, so its unique doesn't matter
Taking TyVars apart
tyVarName :: TyVar -> NameSource
tyVarKind :: TyVar -> KindSource
tcTyVarDetails :: Var -> TcTyVarDetailsSource
Modifying TyVars
setTyVarName :: TyVar -> Name -> TyVarSource
setTyVarUnique :: TyVar -> Unique -> TyVarSource
setTyVarKind :: TyVar -> Kind -> TyVarSource
Coercion variable data type
type CoVar = TyVarSource
Constructing CoVars
mkCoVar :: Name -> Kind -> CoVarSource
Taking CoVars apart
coVarName :: CoVar -> NameSource
Modifying CoVars
setCoVarUnique :: CoVar -> Unique -> CoVarSource
setCoVarName :: CoVar -> Name -> CoVarSource
Var type synonyms
type Id = VarSource
type DictId = VarSource
Produced by Haddock version 2.6.1