| Safe Haskell | None |
|---|
Var
Contents
Description
GHC uses several kinds of name internally:
-
OccName: see OccName -
RdrName: see RdrName -
Name: see Name -
Id: see Id -
Varis a synonym for theIdtype but it may additionally potentially contain type variables, which have aKindrather than aTypeand 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.
- data Var
- type CoVar = Id
- type Id = Var
- type DictId = EvId
- type DFunId = Id
- type EvVar = EvId
- type EqVar = EvId
- type EvId = Id
- type IpId = EvId
- type TyVar = Var
- type TypeVar = Var
- type KindVar = Var
- type TKVar = 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
- mkCoVar :: Name -> Type -> CoVar
- idInfo :: Id -> IdInfo
- idDetails :: Id -> IdDetails
- lazySetIdInfo :: Id -> IdInfo -> Var
- setIdDetails :: Id -> IdDetails -> Id
- globaliseId :: Id -> Id
- setIdExported :: Id -> Id
- setIdNotExported :: Id -> Id
- isId :: Var -> Bool
- isTKVar :: Var -> Bool
- isTyVar :: Var -> Bool
- isTcTyVar :: Var -> Bool
- isLocalVar :: Var -> Bool
- isLocalId :: Var -> Bool
- isGlobalId :: Var -> Bool
- isExportedId :: Var -> Bool
- mustHaveLocalBinding :: Var -> Bool
- mkTyVar :: Name -> Kind -> TyVar
- mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
- mkKindVar :: Name -> SuperKind -> KindVar
- tyVarName :: TyVar -> Name
- tyVarKind :: TyVar -> Kind
- tcTyVarDetails :: TyVar -> TcTyVarDetails
- setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar
- setTyVarName :: TyVar -> Name -> TyVar
- setTyVarUnique :: TyVar -> Unique -> TyVar
- setTyVarKind :: TyVar -> Kind -> TyVar
- updateTyVarKind :: (Kind -> Kind) -> TyVar -> TyVar
- updateTyVarKindM :: Monad m => (Kind -> m Kind) -> TyVar -> m TyVar
The main data type and synonyms
Taking Vars apart
Modifying Vars
setVarName :: Var -> Name -> VarSource
setVarUnique :: Var -> Unique -> VarSource
setVarType :: Id -> Type -> IdSource
Constructing, taking apart, modifying Ids
mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> IdSource
Exported Vars will not be removed as dead code
lazySetIdInfo :: Id -> IdInfo -> VarSource
setIdDetails :: Id -> IdDetails -> IdSource
globaliseId :: Id -> IdSource
If it's a local, make it global
setIdExported :: Id -> IdSource
setIdNotExported :: Id -> IdSource
We can only do this to LocalIds
Predicates
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.
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
Constructing TyVars
Taking TyVars apart
setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVarSource
Modifying TyVars
setTyVarName :: TyVar -> Name -> TyVarSource
setTyVarUnique :: TyVar -> Unique -> TyVarSource
setTyVarKind :: TyVar -> Kind -> TyVarSource