ghc-9.10.1: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.Types.Id

Description

GHC uses several kinds of name internally:

Synopsis

The main types

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
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

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 #

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

toConstr :: Var -> Constr #

dataTypeOf :: Var -> DataType #

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

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

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

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

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

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

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

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

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

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

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 Id = Var Source #

Identifier

isId :: Var -> Bool Source #

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

In and Out variants

type InVar = Var Source #

type InId = Id Source #

type OutId = Id Source #

Simple construction

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

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

mkVanillaGlobal :: Name -> Type -> Id Source #

Make a global Id without any extra information at all

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

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

mkLocalId :: HasDebugCallStack => Name -> Mult -> Type -> Id Source #

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

mkLocalCoVar :: Name -> Type -> CoVar Source #

Make a local CoVar

mkLocalIdOrCoVar :: Name -> Mult -> Type -> Id Source #

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

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

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 -> Mult -> Type -> Id Source #

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

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

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

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

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

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

Like mkUserLocal, but checks if we have a coercion type

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

Create a template local for a series of types

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

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

mkTemplateLocal :: Int -> Type -> Id Source #

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

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

Workers get local names. CoreTidy will externalise these if necessary

Taking an Id apart

recordSelectorTyCon :: Id -> RecSelParent Source #

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

Modifying an Id

setIdType :: Id -> Type -> Id Source #

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

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

globaliseId :: Id -> Id Source #

If it's a local, make it global

scaleVarBy :: Mult -> Var -> Var Source #

Like scaleIdBy, but skips non-Ids. Useful for scaling a mixed list of ids and tyvars.

Predicates on Ids

isImplicitId :: Id -> Bool Source #

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 Source #

isStrictId says whether either (a) the Id has a strict demand placed on it or (b) definitely has a "strict type", such that it can always be evaluated strictly (i.e an unlifted type) We need to check (b) as well as (a), because when 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. Returns False if the type is levity polymorphic; False is always safe.

isExportedId :: Var -> Bool Source #

isExportedIdVar means "don't throw this away"

idDataCon :: Id -> DataCon Source #

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

isWorkerLikeId :: Id -> Bool Source #

An Id for which we might require all callers to pass strict arguments properly tagged + evaluated.

See Note [CBV Function Ids]

isDeadEndId :: Var -> Bool Source #

Returns true if an application to n args diverges or throws an exception See Note [Dead ends] in GHC.Types.Demand.

hasNoBinding :: Id -> Bool Source #

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

Join variables

type JoinId = Id Source #

idJoinPointHood :: Var -> JoinPointHood Source #

Doesn't return strictness marks

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

Inline pragma stuff

One-shot lambdas

Reading IdInfo fields

idFunRepArity :: Id -> RepArity Source #

This function counts all arguments post-unarisation, which includes arguments with no runtime representation -- see Note [Unarisation and arity]

idCafInfo :: Id -> CafInfo infixl 1 Source #

idUnfolding :: IdUnfoldingFun Source #

Returns the Ids unfolding, but does not expose the unfolding of a strong loop breaker. See unfoldingInfo.

If you really want the unfolding of a strong loopbreaker, call realIdUnfolding.

realIdUnfolding :: Id -> Unfolding Source #

Expose the unfolding if there is one, including for loop breakers

alwaysActiveUnfoldingFun :: IdUnfoldingFun Source #

Returns an unfolding only if (a) not a strong loop breaker and (b) always active

whenActiveUnfoldingFun :: (Activation -> Bool) -> IdUnfoldingFun Source #

Returns an unfolding only if (a) not a strong loop breaker and (b) active in according to is_active

Writing IdInfo fields

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

zapIdUnfolding :: Id -> Id Source #

Similar to trimUnfolding, but also removes evaldness info.

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

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

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

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

setIdDmdSig :: Id -> DmdSig -> Id infixl 1 Source #

setIdCprSig :: Id -> CprSig -> Id infixl 1 Source #

setIdCbvMarks :: Id -> [CbvMark] -> Id infixl 1 Source #

If all marks are NotMarkedStrict we just set nothing.

asWorkerLikeId :: Id -> Id Source #

Turn this id into a WorkerLikeId if possible.

asNonWorkerLikeId :: Id -> Id Source #

Remove any cbv marks on arguments from a given Id.

idDmdSig :: Id -> DmdSig Source #

Accesses the Id's dmdSigInfo.