ghc-lib-parser-9.8.2.20240223: The GHC API, decoupled from GHC versions
Safe HaskellNone
LanguageHaskell2010

GHC.Types.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
Data Var # 
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 #

NamedThing Var # 
Instance details

Defined in GHC.Types.Var

Methods

getOccName :: Var -> OccName #

getName :: Var -> Name #

HasOccName Var # 
Instance details

Defined in GHC.Types.Var

Methods

occName :: Var -> OccName #

Uniquable Var # 
Instance details

Defined in GHC.Types.Var

Methods

getUnique :: Var -> Unique #

Outputable Var # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: Var -> SDoc #

OutputableBndr Var # 
Instance details

Defined in GHC.Core.Ppr

Eq Var # 
Instance details

Defined in GHC.Types.Var

Methods

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

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

Ord Var # 
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) # 
Instance details

Defined in GHC.Core.Map.Expr

Eq (DeBruijn CoreExpr) # 
Instance details

Defined in GHC.Core.Map.Expr

Eq (DeBruijn Var) # 
Instance details

Defined in GHC.Core.Map.Type

OutputableBndr (Id, TagSig) # 
Instance details

Defined in GHC.Stg.InferTags.TagSig

type Anno Id # 
Instance details

Defined in GHC.Hs.Extension

type Anno (LocatedN Id) # 
Instance details

Defined in GHC.Hs.Binds

type Anno [LocatedN Id] # 
Instance details

Defined in GHC.Hs.Binds

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 GHC.Types.Var.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 :: HasDebugCallStack => Name -> Mult -> Type -> Id #

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

mkLocalCoVar :: Name -> Type -> CoVar #

Make a local CoVar

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

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

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

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

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

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 #

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 #

idMult :: Id -> Mult #

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

setIdMult :: Id -> Mult -> Id #

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

globaliseId :: Id -> Id #

If it's a local, make it global

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

scaleIdBy :: Mult -> Id -> Id #

scaleVarBy :: Mult -> Var -> Var #

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

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 #

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 #

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

isWorkerLikeId :: Id -> Bool #

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

See Note [CBV Function Ids]

isDeadEndId :: Var -> Bool #

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

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 #

isJoinId_maybe :: Var -> Maybe JoinArity #

Doesn't return strictness marks

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

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

Reading IdInfo fields

idFunRepArity :: Id -> RepArity #

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

idCafInfo :: Id -> CafInfo infixl 1 #

idUnfolding :: IdUnfoldingFun #

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 #

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

alwaysActiveUnfoldingFun :: IdUnfoldingFun #

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

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

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 #

zapIdUnfolding :: Id -> Id #

Similar to trimUnfolding, but also removes evaldness info.

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 #

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

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

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

If all marks are NotMarkedStrict we just set nothing.

asWorkerLikeId :: Id -> Id #

Turn this id into a WorkerLikeId if possible.

asNonWorkerLikeId :: Id -> Id #

Remove any cbv marks on arguments from a given Id.

idDmdSig :: Id -> DmdSig #

Accesses the Id's dmdSigInfo.