plutus-core
Safe HaskellNone
LanguageHaskell2010

PlutusCore.Subst

Synopsis

Documentation

substTyVarA :: forall f tyname (uni :: Type -> Type) ann. Applicative f => (tyname -> f (Maybe (Type tyname uni ann))) -> Type tyname uni ann -> f (Type tyname uni ann) Source #

Applicatively replace a type variable using the given function.

substVarA :: forall f name tyname (uni :: Type -> Type) fun ann. Applicative f => (name -> f (Maybe (Term tyname name uni fun ann))) -> Term tyname name uni fun ann -> f (Term tyname name uni fun ann) Source #

Applicatively replace a variable using the given function.

substTyVar :: forall tyname (uni :: Type -> Type) ann. (tyname -> Maybe (Type tyname uni ann)) -> Type tyname uni ann -> Type tyname uni ann Source #

Replace a type variable using the given function.

substVar :: forall name tyname (uni :: Type -> Type) fun ann. (name -> Maybe (Term tyname name uni fun ann)) -> Term tyname name uni fun ann -> Term tyname name uni fun ann Source #

Replace a variable using the given function.

termSubstNamesM :: forall m name tyname (uni :: Type -> Type) fun ann. Monad m => (name -> m (Maybe (Term tyname name uni fun ann))) -> Term tyname name uni fun ann -> m (Term tyname name uni fun ann) Source #

Naively monadically substitute names using the given function (i.e. do not substitute binders).

termSubstTyNamesM :: forall m tyname (uni :: Type -> Type) ann name fun. Monad m => (tyname -> m (Maybe (Type tyname uni ann))) -> Term tyname name uni fun ann -> m (Term tyname name uni fun ann) Source #

Naively monadically substitute type names using the given function (i.e. do not substitute binders).

typeSubstTyNamesM :: forall m tyname (uni :: Type -> Type) ann. Monad m => (tyname -> m (Maybe (Type tyname uni ann))) -> Type tyname uni ann -> m (Type tyname uni ann) Source #

Naively monadically substitute type names (i.e. do not substitute binders). INLINE is important here because the function is too polymorphic (determined from profiling)

termSubstNames :: forall name tyname (uni :: Type -> Type) fun ann. (name -> Maybe (Term tyname name uni fun ann)) -> Term tyname name uni fun ann -> Term tyname name uni fun ann Source #

Naively substitute names using the given function (i.e. do not substitute binders).

termSubstTyNames :: forall tyname (uni :: Type -> Type) ann name fun. (tyname -> Maybe (Type tyname uni ann)) -> Term tyname name uni fun ann -> Term tyname name uni fun ann Source #

Naively substitute type names using the given function (i.e. do not substitute binders).

typeSubstTyNames :: forall tyname (uni :: Type -> Type) ann. (tyname -> Maybe (Type tyname uni ann)) -> Type tyname uni ann -> Type tyname uni ann Source #

Naively substitute type names (i.e. do not substitute binders).

typeSubstClosedType :: forall tyname (uni :: Type -> Type) a. Eq tyname => tyname -> Type tyname uni a -> Type tyname uni a -> Type tyname uni a Source #

Substitute the given closed Type for the given type variable in the given Type. Does not descend under binders that bind the same variable as the one we're substituting for (since from there that variable is no longer free). The resulting Term may and likely will not satisfy global uniqueness.

termSubstClosedType :: forall tyname (uni :: Type -> Type) a name fun. Eq tyname => tyname -> Type tyname uni a -> Term tyname name uni fun a -> Term tyname name uni fun a Source #

Substitute the given closed Type for the given type variable in the given Term. Does not descend under binders that bind the same variable as the one we're substituting for (since from there that variable is no longer free). The resulting Term may and likely will not satisfy global uniqueness.

termSubstClosedTerm :: forall name tyname (uni :: Type -> Type) fun a. Eq name => name -> Term tyname name uni fun a -> Term tyname name uni fun a -> Term tyname name uni fun a Source #

Substitute the given closed Term for the given term variable in the given Term. Does not descend under binders that bind the same variable as the one we're substituting for (since from there that variable is no longer free). The resulting Term may and likely will not satisfy global uniqueness.

typeMapNames :: forall tyname tyname' (uni :: Type -> Type) ann. (tyname -> tyname') -> Type tyname uni ann -> Type tyname' uni ann Source #

termMapNames :: forall tyname tyname' name name' (uni :: Type -> Type) fun ann. (tyname -> tyname') -> (name -> name') -> Term tyname name uni fun ann -> Term tyname' name' uni fun ann Source #

programMapNames :: forall tyname tyname' name name' (uni :: Type -> Type) fun ann. (tyname -> tyname') -> (name -> name') -> Program tyname name uni fun ann -> Program tyname' name' uni fun ann Source #

fvTerm :: forall name unique tyname (uni :: Type -> Type) fun ann. HasUnique name unique => Traversal' (Term tyname name uni fun ann) name Source #

Get all the free term variables in a term.

ftvTerm :: forall tyname unique name (uni :: Type -> Type) fun ann. HasUnique tyname unique => Traversal' (Term tyname name uni fun ann) tyname Source #

Get all the free type variables in a term.

ftvTy :: forall tyname unique (uni :: Type -> Type) ann. HasUnique tyname unique => Traversal' (Type tyname uni ann) tyname Source #

Get all the free type variables in a type.

ftvTyCtx :: forall tyname unique (uni :: Type -> Type) ann. HasUnique tyname unique => UniqueSet unique -> Traversal' (Type tyname uni ann) tyname Source #

vTerm :: forall tyname name (uni :: Type -> Type) fun ann f. (Contravariant f, Applicative f) => (name -> f name) -> Term tyname name uni fun ann -> f (Term tyname name uni fun ann) Source #

Get all the term variables in a term.

tvTerm :: forall tyname name (uni :: Type -> Type) fun ann f. (Contravariant f, Applicative f) => (tyname -> f tyname) -> Term tyname name uni fun ann -> f (Term tyname name uni fun ann) Source #

Get all the type variables in a term.

tvTy :: forall tyname (uni :: Type -> Type) ann f. (Contravariant f, Applicative f) => (tyname -> f tyname) -> Type tyname uni ann -> f (Type tyname uni ann) Source #

Get all the type variables in a type.

substConstantA :: forall f ann (uni :: Type -> Type) tyname name fun. Applicative f => (ann -> Some (ValueOf uni) -> f (Maybe (Term tyname name uni fun ann))) -> Term tyname name uni fun ann -> f (Term tyname name uni fun ann) Source #

Applicatively replace a constant using the given function.

substConstant :: forall ann (uni :: Type -> Type) tyname name fun. (ann -> Some (ValueOf uni) -> Maybe (Term tyname name uni fun ann)) -> Term tyname name uni fun ann -> Term tyname name uni fun ann Source #

Replace a constant using the given function.

termSubstConstantsM :: forall m ann (uni :: Type -> Type) tyname name fun. Monad m => (ann -> Some (ValueOf uni) -> m (Maybe (Term tyname name uni fun ann))) -> Term tyname name uni fun ann -> m (Term tyname name uni fun ann) Source #

Monadically substitute constants using the given function.

termSubstConstants :: forall ann (uni :: Type -> Type) tyname name fun. (ann -> Some (ValueOf uni) -> Maybe (Term tyname name uni fun ann)) -> Term tyname name uni fun ann -> Term tyname name uni fun ann Source #

Substitute constants using the given function.