Safe Haskell | None |
---|---|
Language | Haskell2010 |
GHC uses several kinds of name internally:
OccName
: see GHC.Types.Name.OccurrenceRdrName
: see GHC.Types.Name.ReaderName
: see GHC.Types.NameId
: see GHC.Types.IdVar
is a synonym for theId
type but it may additionally potentially contain type variables, which have aKind
rather than aType
and only contain some extra details during typechecking.
These Var
names may either be global or local, see GHC.Types.Var
Global Id
s and Var
s are those that are imported or correspond
to a data constructor, primitive operation, or record selectors.
Local Id
s and Var
s are those bound within an expression
(e.g. by a lambda) or at the top level of the module being compiled.
Synopsis
- 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 TcTyVar = 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
- varMult :: Var -> Mult
- varMultMaybe :: Id -> Maybe Mult
- setVarName :: Var -> Name -> Var
- setVarUnique :: Var -> Unique -> Var
- setVarType :: Var -> Type -> Var
- updateVarType :: (Type -> Type) -> Var -> Var
- updateVarTypeM :: Monad m => (Type -> m Type) -> Var -> m Var
- mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
- mkLocalVar :: IdDetails -> Name -> Mult -> 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
- setIdMult :: Id -> Mult -> Id
- updateIdTypeButNotMult :: (Type -> Type) -> Id -> Id
- updateIdTypeAndMult :: (Type -> Type) -> Id -> Id
- updateIdTypeAndMultM :: Monad m => (Type -> m Type) -> Id -> m 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 ForAllTyFlag where
- Invisible Specificity
- Required
- pattern Specified :: ForAllTyFlag
- pattern Inferred :: ForAllTyFlag
- data Specificity
- isVisibleForAllTyFlag :: ForAllTyFlag -> Bool
- isInvisibleForAllTyFlag :: ForAllTyFlag -> Bool
- isInferredForAllTyFlag :: ForAllTyFlag -> Bool
- data FunTyFlag
- isVisibleFunArg :: FunTyFlag -> Bool
- isInvisibleFunArg :: FunTyFlag -> Bool
- isFUNArg :: FunTyFlag -> Bool
- mkFunTyFlag :: TypeOrConstraint -> TypeOrConstraint -> FunTyFlag
- visArg :: TypeOrConstraint -> FunTyFlag
- invisArg :: TypeOrConstraint -> FunTyFlag
- visArgTypeLike :: FunTyFlag
- visArgConstraintLike :: FunTyFlag
- invisArgTypeLike :: FunTyFlag
- invisArgConstraintLike :: FunTyFlag
- funTyFlagArgTypeOrConstraint :: FunTyFlag -> TypeOrConstraint
- funTyFlagResultTypeOrConstraint :: FunTyFlag -> TypeOrConstraint
- data TypeOrConstraint
- data PiTyBinder
- type PiTyVarBinder = PiTyBinder
- isInvisiblePiTyBinder :: PiTyBinder -> Bool
- isVisiblePiTyBinder :: PiTyBinder -> Bool
- isTyBinder :: PiTyBinder -> Bool
- isNamedPiTyBinder :: PiTyBinder -> Bool
- isAnonPiTyBinder :: PiTyBinder -> Bool
- namedPiTyBinder_maybe :: PiTyBinder -> Maybe TyCoVar
- anonPiTyBinderType_maybe :: PiTyBinder -> Maybe Type
- piTyBinderType :: PiTyBinder -> Type
- data VarBndr var argf = Bndr var argf
- type ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag
- type TyVarBinder = VarBndr TyVar ForAllTyFlag
- type InvisTyBinder = VarBndr TyCoVar Specificity
- type InvisTVBinder = VarBndr TyVar Specificity
- type ReqTyBinder = VarBndr TyCoVar ()
- type ReqTVBinder = VarBndr TyVar ()
- binderVar :: VarBndr tv argf -> tv
- binderVars :: [VarBndr tv argf] -> [tv]
- binderFlag :: VarBndr tv argf -> argf
- binderFlags :: [VarBndr tv argf] -> [argf]
- binderType :: VarBndr TyCoVar argf -> Type
- mkForAllTyBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis
- mkForAllTyBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis]
- mkTyVarBinder :: vis -> TyVar -> VarBndr TyVar vis
- mkTyVarBinders :: vis -> [TyVar] -> [VarBndr TyVar vis]
- isTyVarBinder :: VarBndr TyCoVar vis -> Bool
- tyVarSpecToBinder :: VarBndr a Specificity -> VarBndr a ForAllTyFlag
- tyVarSpecToBinders :: [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
- tyVarReqToBinder :: VarBndr a () -> VarBndr a ForAllTyFlag
- tyVarReqToBinders :: [VarBndr a ()] -> [VarBndr a ForAllTyFlag]
- mapVarBndr :: (var -> var') -> VarBndr var flag -> VarBndr var' flag
- mapVarBndrs :: (var -> var') -> [VarBndr var flag] -> [VarBndr var' flag]
- 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
Variable
Essentially a typed Name
, that may also contain some additional information
about the Var
and its use sites.
Instances
Data Var Source # | |
Defined in GHC.Types.Var gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Var -> c Var Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Var Source # toConstr :: Var -> Constr Source # dataTypeOf :: Var -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Var) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Var) Source # gmapT :: (forall b. Data b => b -> b) -> Var -> Var Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Var -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Var -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Var -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Var -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Var -> m Var Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Var -> m Var Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Var -> m Var Source # | |
NamedThing Var Source # | |
HasOccName Var Source # | |
Uniquable Var Source # | |
Outputable Var Source # | |
OutputableBndr Var Source # | |
Defined in GHC.Core.Ppr | |
Eq Var Source # | |
Ord Var Source # | |
Eq (DeBruijn CoreAlt) Source # | |
Eq (DeBruijn CoreExpr) Source # | |
Eq (DeBruijn Var) Source # | |
OutputableBndr (Id, TagSig) Source # | |
type Anno Id Source # | |
Defined in GHC.Hs.Extension | |
type Anno (LocatedN Id) Source # | |
Defined in GHC.Hs.Binds | |
type Anno [LocatedN Id] Source # | |
Defined in GHC.Hs.Binds |
In and Out variants
Taking Var
s apart
Modifying Var
s
Constructing, taking apart, modifying Id
s
mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id Source #
Exported Var
s will not be removed as dead code
globaliseId :: Id -> Id Source #
If it's a local, make it global
setIdExported :: Id -> Id Source #
setIdNotExported :: Id -> Id Source #
We can only do this to LocalIds
Predicates
Is this a value-level (i.e., computationally relevant) Id
entifier?
Satisfies isId = not . isTyVar
.
isTyVar :: Var -> Bool Source #
Is this a type-level (i.e., computationally irrelevant, thus erasable)
variable? Satisfies isTyVar = not . isId
.
isLocalVar :: Var -> Bool Source #
isLocalVar
returns True
for type variables as well as local Id
s
These are the variables that we need to pay attention to when finding free
variables, or doing dependency analysis.
isCoVar :: Var -> Bool Source #
Is this a coercion variable?
Satisfies
.isId
v ==> isCoVar
v == not (isNonCoVarId
v)
isNonCoVarId :: Var -> Bool Source #
Is this a term variable (Id
) that is not a coercion variable?
Satisfies
.isId
v ==> isCoVar
v == not (isNonCoVarId
v)
isGlobalId :: Var -> Bool Source #
isExportedId :: Var -> Bool Source #
isExportedIdVar
means "don't throw this away"
mustHaveLocalBinding :: Var -> Bool Source #
mustHaveLocalBinding
returns True
of Id
s and TyVar
s
that must have a binding in this module. The converse
is not quite right: there are some global Id
s that must have
bindings, such as record selectors. But that doesn't matter,
because it's only used for assertions
ForAllTyFlags
data ForAllTyFlag Source #
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
pattern Specified :: ForAllTyFlag | |
pattern Inferred :: ForAllTyFlag |
Instances
data Specificity Source #
Whether an Invisible
argument may appear in source Haskell.
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. |
Instances
isVisibleForAllTyFlag :: ForAllTyFlag -> Bool Source #
Does this ForAllTyFlag
classify an argument that is written in Haskell?
isInvisibleForAllTyFlag :: ForAllTyFlag -> Bool Source #
Does this ForAllTyFlag
classify an argument that is not written in Haskell?
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
Instances
Data FunTyFlag Source # | |
Defined in GHC.Types.Var gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FunTyFlag -> c FunTyFlag Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FunTyFlag Source # toConstr :: FunTyFlag -> Constr Source # dataTypeOf :: FunTyFlag -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FunTyFlag) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FunTyFlag) Source # gmapT :: (forall b. Data b => b -> b) -> FunTyFlag -> FunTyFlag Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r Source # gmapQ :: (forall d. Data d => d -> u) -> FunTyFlag -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> FunTyFlag -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag Source # | |
Binary FunTyFlag Source # | |
Outputable FunTyFlag Source # | |
Eq FunTyFlag Source # | |
Ord FunTyFlag Source # | |
Defined in GHC.Types.Var |
isVisibleFunArg :: FunTyFlag -> Bool Source #
isInvisibleFunArg :: FunTyFlag -> Bool Source #
visArg :: TypeOrConstraint -> FunTyFlag Source #
invisArg :: TypeOrConstraint -> FunTyFlag Source #
data TypeOrConstraint Source #
Instances
PiTyBinder
data PiTyBinder Source #
A PiTyBinder
represents an argument to a function. PiTyBinders can be
dependent (Named
) or nondependent (Anon
). They may also be visible or
not. See Note [PiTyBinders]
Instances
Data PiTyBinder Source # | |
Defined in GHC.Types.Var gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PiTyBinder -> c PiTyBinder Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PiTyBinder Source # toConstr :: PiTyBinder -> Constr Source # dataTypeOf :: PiTyBinder -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PiTyBinder) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PiTyBinder) Source # gmapT :: (forall b. Data b => b -> b) -> PiTyBinder -> PiTyBinder Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r Source # gmapQ :: (forall d. Data d => d -> u) -> PiTyBinder -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> PiTyBinder -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder Source # | |
Outputable PiTyBinder Source # | |
Defined in GHC.Types.Var ppr :: PiTyBinder -> SDoc Source # |
type PiTyVarBinder = PiTyBinder Source #
PiTyVarBinder
is like PiTyBinder
, but there can only be TyVar
in the Named
field.
isInvisiblePiTyBinder :: PiTyBinder -> Bool Source #
Does this binder bind an invisible argument?
isVisiblePiTyBinder :: PiTyBinder -> Bool Source #
Does this binder bind a visible argument?
isTyBinder :: PiTyBinder -> Bool Source #
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.
isNamedPiTyBinder :: PiTyBinder -> Bool Source #
isAnonPiTyBinder :: PiTyBinder -> Bool Source #
Does this binder bind a variable that is not erased? Returns
True
for anonymous binders.
anonPiTyBinderType_maybe :: PiTyBinder -> Maybe Type Source #
Extract a relevant type, if there is one.
piTyBinderType :: PiTyBinder -> Type Source #
TyVar's
data VarBndr var argf Source #
Bndr var argf |
Instances
(Data var, Data argf) => Data (VarBndr var argf) Source # | |
Defined in GHC.Types.Var gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> VarBndr var argf -> c (VarBndr var argf) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (VarBndr var argf) Source # toConstr :: VarBndr var argf -> Constr Source # dataTypeOf :: VarBndr var argf -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (VarBndr var argf)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (VarBndr var argf)) Source # gmapT :: (forall b. Data b => b -> b) -> VarBndr var argf -> VarBndr var argf Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r Source # gmapQ :: (forall d. Data d => d -> u) -> VarBndr var argf -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> VarBndr var argf -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> VarBndr var argf -> m (VarBndr var argf) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> VarBndr var argf -> m (VarBndr var argf) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> VarBndr var argf -> m (VarBndr var argf) Source # | |
NamedThing tv => NamedThing (VarBndr tv flag) Source # | |
(Binary tv, Binary vis) => Binary (VarBndr tv vis) Source # | |
OutputableBndr tv => Outputable (VarBndr tv TyConBndrVis) Source # | |
Defined in GHC.Core.TyCon | |
Outputable tv => Outputable (VarBndr tv ForAllTyFlag) Source # | |
Defined in GHC.Types.Var | |
Outputable tv => Outputable (VarBndr tv Specificity) Source # | |
Defined in GHC.Types.Var |
type ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag Source #
Variable Binder
A ForAllTyBinder
is the binder of a ForAllTy
It's convenient to define this synonym here rather its natural
home in GHC.Core.TyCo.Rep, because it's used in GHC.Core.DataCon.hs-boot
A TyVarBinder
is a binder with only TyVar
type TyVarBinder = VarBndr TyVar ForAllTyFlag Source #
type InvisTyBinder = VarBndr TyCoVar Specificity Source #
type InvisTVBinder = VarBndr TyVar Specificity Source #
type ReqTyBinder = VarBndr TyCoVar () Source #
type ReqTVBinder = VarBndr TyVar () Source #
binderVars :: [VarBndr tv argf] -> [tv] Source #
binderFlag :: VarBndr tv argf -> argf Source #
binderFlags :: [VarBndr tv argf] -> [argf] Source #
mkTyVarBinder :: vis -> TyVar -> VarBndr TyVar vis Source #
Make a named binder
var
should be a type variable
mkTyVarBinders :: vis -> [TyVar] -> [VarBndr TyVar vis] Source #
Make many named binders Input vars should be type variables
tyVarSpecToBinder :: VarBndr a Specificity -> VarBndr a ForAllTyFlag Source #
tyVarSpecToBinders :: [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag] Source #
tyVarReqToBinder :: VarBndr a () -> VarBndr a ForAllTyFlag Source #
tyVarReqToBinders :: [VarBndr a ()] -> [VarBndr a ForAllTyFlag] Source #
mapVarBndr :: (var -> var') -> VarBndr var flag -> VarBndr var' flag Source #
mapVarBndrs :: (var -> var') -> [VarBndr var flag] -> [VarBndr var' flag] Source #
Constructing TyVar's
Taking TyVar
s apart
tcTyVarDetails :: TyVar -> TcTyVarDetails Source #
setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar Source #