ghc-8.10.1: The GHC API
Safe HaskellNone
LanguageHaskell2010

Id

Description

GHC uses several kinds of name internally:

Synopsis

The main types

data Var #

Variable

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

Instances

Instances details
Eq Var # 
Instance details

Defined in Var

Methods

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

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

Data Var # 
Instance details

Defined in 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 #

Ord Var # 
Instance details

Defined in 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 #

OutputableBndr Var # 
Instance details

Defined in PprCore

Outputable Var # 
Instance details

Defined in Var

Methods

ppr :: Var -> SDoc #

pprPrec :: Rational -> Var -> SDoc #

Uniquable Var # 
Instance details

Defined in Var

Methods

getUnique :: Var -> Unique #

HasOccName Var # 
Instance details

Defined in Var

Methods

occName :: Var -> OccName #

NamedThing Var # 
Instance details

Defined in Var

Methods

getOccName :: Var -> OccName #

getName :: Var -> Name #

type Id = Var #

Identifier

isId :: Var -> Bool #

Is this a value-level (i.e., computationally relevant) Identifier? Satisfies isId = not . isTyVar.

In and Out variants

type InVar = Var #

type InId = Id #

type OutVar = Var #

type OutId = Id #

Simple construction

mkGlobalId :: IdDetails -> Name -> Type -> IdInfo -> Id #

For an explanation of global vs. local Ids, see Var

mkVanillaGlobal :: Name -> Type -> Id #

Make a global Id without any extra information at all

mkVanillaGlobalWithInfo :: Name -> Type -> IdInfo -> Id #

Make a global Id with no global information but some generic IdInfo

mkLocalId :: Name -> Type -> Id #

For an explanation of global vs. local Ids, see Var

mkLocalCoVar :: Name -> Type -> CoVar #

Make a local CoVar

mkLocalIdOrCoVar :: Name -> Type -> Id #

Like mkLocalId, but checks the type to see if it should make a covar

mkLocalIdOrCoVarWithInfo :: Name -> Type -> IdInfo -> Id #

Make a local id, with the IdDetails set to CoVarId if the type indicates so.

mkExportedLocalId :: IdDetails -> Name -> Type -> Id #

Create a local Id that is marked as exported. This prevents things attached to it from being removed as dead code. See Note [Exported LocalIds]

mkSysLocal :: FastString -> Unique -> Type -> Id #

Create a system local Id. These are local Ids (see Var) that are created by the compiler out of thin air

mkSysLocalOrCoVar :: FastString -> Unique -> Type -> Id #

Like mkSysLocal, but checks to see if we have a covar type

mkUserLocal :: OccName -> Unique -> Type -> SrcSpan -> Id #

Create a user local Id. These are local Ids (see Var) with a name and location that the user might recognize

mkUserLocalOrCoVar :: OccName -> Unique -> Type -> SrcSpan -> Id #

Like mkUserLocal, but checks if we have a coercion type

mkTemplateLocals :: [Type] -> [Id] #

Create a template local for a series of types

mkTemplateLocalsNum :: Int -> [Type] -> [Id] #

Create a template local for a series of type, but start from a specified template local

mkTemplateLocal :: Int -> Type -> Id #

Create a template local: a family of system local Ids in bijection with Ints, typically used in unfoldings

mkWorkerId :: Unique -> Id -> Type -> Id #

Workers get local names. CoreTidy will externalise these if necessary

Taking an Id apart

idName :: Id -> Name #

idType :: Id -> Kind #

recordSelectorTyCon :: Id -> RecSelParent #

If the Id is that for a record selector, extract the sel_tycon. Panic otherwise.

Modifying an Id

setIdName :: Id -> Name -> Id #

setIdType :: Id -> Type -> Id #

Not only does this set the Id Type, it also evaluates the type to try and reduce space usage

globaliseId :: Id -> Id #

If it's a local, make it global

transferPolyIdInfo :: Id -> [Var] -> Id -> Id #

Predicates on Ids

isImplicitId :: Id -> Bool #

isImplicitId tells whether an Ids info is implied by other declarations, so we don't need to put its signature in an interface file, even if it's mentioned in some other interface unfolding.

isStrictId :: Id -> Bool #

This predicate says whether the Id has a strict demand placed on it or has a type such that it can always be evaluated strictly (i.e an unlifted type, as of GHC 7.6). We need to check separately whether the Id has a so-called "strict type" because if the demand for the given id hasn't been computed yet but id has a strict type, we still want isStrictId id to be True.

isExportedId :: Var -> Bool #

isExportedIdVar means "don't throw this away"

idDataCon :: Id -> DataCon #

Get from either the worker or the wrapper Id to the DataCon. Currently used only in the desugarer.

INVARIANT: idDataCon (dataConWrapId d) = d: remember, dataConWrapId can return either the wrapper or the worker

isBottomingId :: Var -> Bool #

Returns true if an application to n args would diverge

hasNoBinding :: Id -> Bool #

Returns True of an Id which may not have a binding, even though it is defined in this module.

Join variables

type JoinId = Id #

asJoinId :: Id -> JoinArity -> JoinId infixl 1 #

asJoinId_maybe :: Id -> Maybe JoinArity -> Id infixl 1 #

Inline pragma stuff

setInlinePragma :: Id -> InlinePragma -> Id infixl 1 #

One-shot lambdas

isOneShotBndr :: Var -> Bool #

Returns whether the lambda associated with the Id is certainly applied at most once This one is the "business end", called externally. It works on type variables as well as Ids, returning True Its main purpose is to encapsulate the Horrible State Hack See Note [The state-transformer hack] in CoreArity

setIdOneShotInfo :: Id -> OneShotInfo -> Id infixl 1 #

stateHackOneShot :: OneShotInfo #

Should we apply the state hack to values of this Type?

Reading IdInfo fields

idCafInfo :: Id -> CafInfo infixl 1 #

idStateHackOneShotInfo :: Id -> OneShotInfo #

Like idOneShotInfo, but taking the Horrible State Hack in to account See Note [The state-transformer hack] in CoreArity

Writing IdInfo fields

setIdUnfolding :: Id -> Unfolding -> Id infixl 1 #

setIdArity :: Id -> Arity -> Id infixl 1 #

setIdCallArity :: Id -> Arity -> Id infixl 1 #

setIdSpecialisation :: Id -> RuleInfo -> Id infixl 1 #

setIdOccInfo :: Id -> OccInfo -> Id infixl 1 #

setIdDemandInfo :: Id -> Demand -> Id infixl 1 #

setIdStrictness :: Id -> StrictSig -> Id infixl 1 #

idStrictness :: Id -> StrictSig #

Accesses the Id's strictnessInfo.