ghc-9.6.0.20230302: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Types.Var

Description

GHC uses several kinds of name internally:

These Var names may either be global or local, see GHC.Types.Var

Global Vars and Vars are those that are imported or correspond to a data constructor, primitive operation, or record selectors. Local Vars and Vars are those bound within an expression (e.g. by a lambda) or at the top level of the module being compiled.

Synopsis

The main data type and synonyms

data Var Source #

Variable

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

Instances

Instances details
Data Var Source # 
Instance details

Defined in GHC.Types.Var

Methods

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 # 
Instance details

Defined in GHC.Types.Var

HasOccName Var Source # 
Instance details

Defined in GHC.Types.Var

Methods

occName :: Var -> OccName Source #

Uniquable Var Source # 
Instance details

Defined in GHC.Types.Var

Methods

getUnique :: Var -> Unique Source #

Outputable Var Source # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: Var -> SDoc Source #

OutputableBndr Var Source # 
Instance details

Defined in GHC.Core.Ppr

Eq Var Source # 
Instance details

Defined in GHC.Types.Var

Methods

(==) :: Var -> Var -> Bool #

(/=) :: Var -> Var -> Bool #

Ord Var Source # 
Instance details

Defined in GHC.Types.Var

Methods

compare :: Var -> Var -> Ordering #

(<) :: Var -> Var -> Bool #

(<=) :: Var -> Var -> Bool #

(>) :: Var -> Var -> Bool #

(>=) :: Var -> Var -> Bool #

max :: Var -> Var -> Var #

min :: Var -> Var -> Var #

Eq (DeBruijn CoreAlt) Source # 
Instance details

Defined in GHC.Core.Map.Expr

Eq (DeBruijn CoreExpr) Source # 
Instance details

Defined in GHC.Core.Map.Expr

Eq (DeBruijn Var) Source # 
Instance details

Defined in GHC.Core.Map.Type

OutputableBndr (Id, TagSig) Source # 
Instance details

Defined in GHC.Stg.InferTags.TagSig

type Anno Id Source # 
Instance details

Defined in GHC.Hs.Extension

type Anno (LocatedN Id) Source # 
Instance details

Defined in GHC.Hs.Binds

type Anno [LocatedN Id] Source # 
Instance details

Defined in GHC.Hs.Binds

type CoVar = Id Source #

Coercion Variable

type Id = Var Source #

Identifier

type NcId = Id Source #

 

type DictId = EvId Source #

Dictionary Identifier

type DFunId = Id Source #

Dictionary Function Identifier

type EvVar = EvId Source #

Evidence Variable

type EqVar = EvId Source #

Equality Variable

type EvId = Id Source #

Evidence Identifier

type IpId = EvId Source #

Implicit parameter Identifier

type JoinId = Id Source #

type TyVar = Var Source #

Type or kind Variable

type TcTyVar = Var Source #

Type variable that might be a metavariable

type TypeVar = Var Source #

Type Variable

type KindVar = Var Source #

Kind Variable

type TKVar = Var Source #

Type or Kind Variable

type TyCoVar = Id Source #

Type or Coercion Variable

In and Out variants

type InVar = Var Source #

type InId = Id Source #

type OutId = Id Source #

Taking Vars apart

varType :: Var -> Kind Source #

The type or kind of the Var in question

Modifying Vars

updateVarType :: (Type -> Type) -> Var -> Var Source #

Update a Vars type. Does not update the multiplicity stored in an Var, if any. Because of the possibility for abuse, ASSERTs that there is no multiplicity to update.

updateVarTypeM :: Monad m => (Type -> m Type) -> Var -> m Var Source #

Update a Vars type monadically. Does not update the multiplicity stored in an Var, if any. Because of the possibility for abuse, ASSERTs that there is no multiplicity to update.

Constructing, taking apart, modifying Vars

mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id Source #

Exported Vars will not be removed as dead code

globaliseId :: Id -> Id Source #

If it's a local, make it global

setIdExported :: Id -> Id Source #

Exports the given local Var. Can also be called on global Vars, such as data constructors and class operations, which are born as global Vars and automatically exported

setIdNotExported :: Id -> Id Source #

We can only do this to LocalIds

updateIdTypeAndMultM :: Monad m => (Type -> m Type) -> Id -> m Id Source #

Predicates

isId :: Var -> Bool Source #

Is this a value-level (i.e., computationally relevant) Varentifier? 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 Vars 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 (Var) that is not a coercion variable? Satisfies isId v ==> isCoVar v == not (isNonCoVarId v).

isExportedId :: Var -> Bool Source #

isExportedIdVar means "don't throw this away"

mustHaveLocalBinding :: Var -> Bool Source #

mustHaveLocalBinding returns True of Vars and Vars that must have a binding in this module. The converse is not quite right: there are some global Vars 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

Bundled Patterns

pattern Specified :: ForAllTyFlag 
pattern Inferred :: ForAllTyFlag 

Instances

Instances details
Data ForAllTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ForAllTyFlag -> c ForAllTyFlag Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ForAllTyFlag Source #

toConstr :: ForAllTyFlag -> Constr Source #

dataTypeOf :: ForAllTyFlag -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ForAllTyFlag) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ForAllTyFlag) Source #

gmapT :: (forall b. Data b => b -> b) -> ForAllTyFlag -> ForAllTyFlag Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ForAllTyFlag -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ForAllTyFlag -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ForAllTyFlag -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ForAllTyFlag -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ForAllTyFlag -> m ForAllTyFlag Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ForAllTyFlag -> m ForAllTyFlag Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ForAllTyFlag -> m ForAllTyFlag Source #

Binary ForAllTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Outputable ForAllTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Eq ForAllTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Ord ForAllTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Outputable tv => Outputable (VarBndr tv ForAllTyFlag) Source # 
Instance details

Defined in GHC.Types.Var

data Specificity Source #

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.

Instances

Instances details
Data Specificity Source # 
Instance details

Defined in GHC.Types.Var

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Specificity -> c Specificity Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Specificity Source #

toConstr :: Specificity -> Constr Source #

dataTypeOf :: Specificity -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Specificity) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Specificity) Source #

gmapT :: (forall b. Data b => b -> b) -> Specificity -> Specificity Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Specificity -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Specificity -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Specificity -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Specificity -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Specificity -> m Specificity Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Specificity -> m Specificity Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Specificity -> m Specificity Source #

Binary Specificity Source # 
Instance details

Defined in GHC.Types.Var

Eq Specificity Source # 
Instance details

Defined in GHC.Types.Var

Ord Specificity Source # 
Instance details

Defined in GHC.Types.Var

OutputableBndrFlag Specificity p Source # 
Instance details

Defined in GHC.Hs.Type

Outputable tv => Outputable (VarBndr tv Specificity) Source # 
Instance details

Defined in GHC.Types.Var

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

data FunTyFlag Source #

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

Constructors

FTF_T_T 
FTF_T_C 
FTF_C_T 
FTF_C_C 

Instances

Instances details
Data FunTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Methods

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 # 
Instance details

Defined in GHC.Types.Var

Outputable FunTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: FunTyFlag -> SDoc Source #

Eq FunTyFlag Source # 
Instance details

Defined in GHC.Types.Var

Ord FunTyFlag Source # 
Instance details

Defined in GHC.Types.Var

data TypeOrConstraint Source #

Constructors

TypeLike 
ConstraintLike 

Instances

Instances details
Data TypeOrConstraint Source # 
Instance details

Defined in GHC.Types.Basic

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeOrConstraint -> c TypeOrConstraint Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeOrConstraint Source #

toConstr :: TypeOrConstraint -> Constr Source #

dataTypeOf :: TypeOrConstraint -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeOrConstraint) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeOrConstraint) Source #

gmapT :: (forall b. Data b => b -> b) -> TypeOrConstraint -> TypeOrConstraint Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeOrConstraint -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeOrConstraint -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TypeOrConstraint -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeOrConstraint -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeOrConstraint -> m TypeOrConstraint Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeOrConstraint -> m TypeOrConstraint Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeOrConstraint -> m TypeOrConstraint Source #

Eq TypeOrConstraint Source # 
Instance details

Defined in GHC.Types.Basic

Ord TypeOrConstraint Source # 
Instance details

Defined in GHC.Types.Basic

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

Instances details
Data PiTyBinder Source # 
Instance details

Defined in GHC.Types.Var

Methods

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 # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: PiTyBinder -> SDoc Source #

type PiTyVarBinder = PiTyBinder Source #

PiTyVarBinder is like PiTyBinder, but there can only be Var 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.

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.

TyVar's

data VarBndr var argf Source #

Constructors

Bndr var argf 

Instances

Instances details
(Data var, Data argf) => Data (VarBndr var argf) Source # 
Instance details

Defined in GHC.Types.Var

Methods

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 # 
Instance details

Defined in GHC.Types.Var

Methods

getOccName :: VarBndr tv flag -> OccName Source #

getName :: VarBndr tv flag -> Name Source #

(Binary tv, Binary vis) => Binary (VarBndr tv vis) Source # 
Instance details

Defined in GHC.Types.Var

Methods

put_ :: BinHandle -> VarBndr tv vis -> IO () Source #

put :: BinHandle -> VarBndr tv vis -> IO (Bin (VarBndr tv vis)) Source #

get :: BinHandle -> IO (VarBndr tv vis) Source #

OutputableBndr tv => Outputable (VarBndr tv TyConBndrVis) Source # 
Instance details

Defined in GHC.Core.TyCon

Outputable tv => Outputable (VarBndr tv ForAllTyFlag) Source # 
Instance details

Defined in GHC.Types.Var

Outputable tv => Outputable (VarBndr tv Specificity) Source # 
Instance details

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

binderVar :: VarBndr tv argf -> tv Source #

binderVars :: [VarBndr tv argf] -> [tv] Source #

binderFlag :: VarBndr tv argf -> argf Source #

binderFlags :: [VarBndr tv argf] -> [argf] Source #

mkForAllTyBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis Source #

Make a named binder

mkForAllTyBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis] Source #

Make many named binders

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

mapVarBndr :: (var -> var') -> VarBndr var flag -> VarBndr var' flag Source #

mapVarBndrs :: (var -> var') -> [VarBndr var flag] -> [VarBndr var' flag] Source #

Constructing TyVar's

Taking Vars apart

Modifying Vars

nonDetCmpVar :: Var -> Var -> Ordering Source #

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]