| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Var
Contents
Description
GHC uses several kinds of name internally:
OccName: see OccNameRdrName: see RdrNameName: see NameId: see IdVaris 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 NcId = Id
- type DictId = EvId
- type DFunId = Id
- type EvVar = EvId
- type EqVar = EvId
- type EvId = Id
- type IpId = EvId
- type JoinId = Id
- type TyVar = Var
- type TypeVar = Var
- type KindVar = Var
- type TKVar = Var
- type TyCoVar = Id
- type InVar = Var
- type InCoVar = CoVar
- type InId = Id
- type InTyVar = TyVar
- type OutVar = Var
- type OutCoVar = CoVar
- type OutId = Id
- type OutTyVar = TyVar
- varName :: Var -> Name
- varUnique :: Var -> Unique
- varType :: Var -> Kind
- setVarName :: Var -> Name -> Var
- setVarUnique :: Var -> Unique -> Var
- setVarType :: Id -> Type -> Id
- updateVarType :: (Type -> Type) -> Id -> Id
- updateVarTypeM :: Monad m => (Type -> m Type) -> Id -> m Id
- mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
- mkLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
- mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
- mkCoVar :: Name -> Type -> CoVar
- idInfo :: HasDebugCallStack => 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
- isTyVar :: Var -> Bool
- isTcTyVar :: Var -> Bool
- isLocalVar :: Var -> Bool
- isLocalId :: Var -> Bool
- isCoVar :: Var -> Bool
- isNonCoVarId :: Var -> Bool
- isTyCoVar :: Var -> Bool
- isGlobalId :: Var -> Bool
- isExportedId :: Var -> Bool
- mustHaveLocalBinding :: Var -> Bool
- data TyVarBndr tyvar argf = TvBndr tyvar argf
- data ArgFlag
- type TyVarBinder = TyVarBndr TyVar ArgFlag
- binderVar :: TyVarBndr tv argf -> tv
- binderVars :: [TyVarBndr tv argf] -> [tv]
- binderArgFlag :: TyVarBndr tv argf -> argf
- binderKind :: TyVarBndr TyVar argf -> Kind
- isVisibleArgFlag :: ArgFlag -> Bool
- isInvisibleArgFlag :: ArgFlag -> Bool
- sameVis :: ArgFlag -> ArgFlag -> Bool
- mkTyVar :: Name -> Kind -> TyVar
- mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
- 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
- nonDetCmpVar :: Var -> Var -> Ordering
The main data type and synonyms
In and Out variants
Taking Vars apart
Modifying Vars
setVarName :: Var -> Name -> Var #
setVarUnique :: Var -> Unique -> Var #
setVarType :: Id -> Type -> Id #
Constructing, taking apart, modifying Ids
mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id #
Exported Vars will not be removed as dead code
idInfo :: HasDebugCallStack => Id -> IdInfo #
lazySetIdInfo :: Id -> IdInfo -> Var #
setIdDetails :: Id -> IdDetails -> Id #
globaliseId :: Id -> Id #
If it's a local, make it global
setIdExported :: Id -> Id #
setIdNotExported :: Id -> Id #
We can only do this to LocalIds
Predicates
isLocalVar :: 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.
isNonCoVarId :: Var -> Bool #
isGlobalId :: Var -> Bool #
isExportedId :: Var -> Bool #
isExportedIdVar means "don't throw this away"
mustHaveLocalBinding :: Var -> Bool #
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
TyVar's
Constructors
| TvBndr tyvar argf |
Instances
| (Data argf, Data tyvar) => Data (TyVarBndr tyvar argf) # | |
| Outputable tv => Outputable (TyVarBndr tv ArgFlag) # | |
| Outputable tv => Outputable (TyVarBndr tv TyConBndrVis) # | |
| (Binary tv, Binary vis) => Binary (TyVarBndr tv vis) # | |
type TyVarBinder = TyVarBndr TyVar ArgFlag #
Type Variable Binder
A TyVarBinder is the binder of a ForAllTy
It's convenient to define this synonym here rather its natural
home in TyCoRep, because it's used in DataCon.hs-boot
binderVars :: [TyVarBndr tv argf] -> [tv] #
binderArgFlag :: TyVarBndr tv argf -> argf #
binderKind :: TyVarBndr TyVar argf -> Kind #
isVisibleArgFlag :: ArgFlag -> Bool #
Does this ArgFlag classify an argument that is written in Haskell?
isInvisibleArgFlag :: ArgFlag -> Bool #
Does this ArgFlag classify an argument that is not written in Haskell?
Constructing TyVar's
Taking TyVars apart
tcTyVarDetails :: TyVar -> TcTyVarDetails #
setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar #
Modifying TyVars
setTyVarName :: TyVar -> Name -> TyVar #
setTyVarUnique :: TyVar -> Unique -> TyVar #
setTyVarKind :: TyVar -> Kind -> TyVar #
nonDetCmpVar :: 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]