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

GHC.Stg.Subst

Synopsis

Documentation

data Subst Source #

A renaming substitution from Ids to Ids. Like RnEnv2, but not maintaining pairs of substitutions. Like Subst, but with the domain being Ids instead of entire CoreExpr.

mkEmptySubst :: InScopeSet -> Subst Source #

Constructs a new Subst assuming the variables in the given InScopeSet are in scope.

substBndr :: Id -> Subst -> (Id, Subst) Source #

Substitutes an Id for another one according to the Subst given in a way that avoids shadowing the InScopeSet, returning the result and an updated Subst that should be used by subsequent substitutions.

substBndrs :: Traversable f => f Id -> Subst -> (f Id, Subst) Source #

substBndrs = runState . traverse (state . substBndr)

lookupIdSubst :: HasCallStack => Id -> Subst -> Id Source #

Substitutes an occurrence of an identifier for its counterpart recorded in the Subst.

noWarnLookupIdSubst :: HasCallStack => Id -> Subst -> Id Source #

Substitutes an occurrence of an identifier for its counterpart recorded in the Subst. Does not generate a debug warning if the identifier to to substitute wasn't in scope.

extendInScope :: Id -> Subst -> Subst Source #

Add the Id to the in-scope set and remove any existing substitutions for it.

extendSubst :: Id -> Id -> Subst -> Subst Source #

Add a substitution for an Id to the Subst: you must ensure that the in-scope set is such that TyCoSubst Note [The substitution invariant] holds after extending the substitution like this.