plutus-core-1.36.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusIR.Core.Instance.Scoping

Synopsis

Documentation

establishScopingParams ∷ [TyVarDecl TyName ann] → Quote [TyVarDecl TyName NameAnn] Source #

Establish scoping for each of the parameters of a datatype by only annotating every parameter with introduceBound.

establishScopingConstrTy ∷ (TyNameNameAnn) → TyName → [TyVarDecl TyName NameAnn] → Type TyName uni ann → Quote (Type TyName uni NameAnn) Source #

Establish scoping for the type of a constructor. The updated constructor expects an argument of the "the data type applied to all its parameters" type (that argument is the last one) and always returns that exact type as a result. For example, this functions turns the following generated type of constructor

integer -> a -> a_non_-_type>

into

integer -> a -> D a b -> D a b

assuming the constructor is supposed to construct a data type D parameterized by two parameters a and b. Note that a_non_-_type> can be anything as the generator is allowed to generate mess such as a constructor not actually constructing a value of the data type.

Whether the name of the data type is referenced as in-scope or out-of-scope one in the types of arguments of constructors is controlled by the first argument, which ultimately depends on the recursivity of the data type.

establishScopingConstrs ∷ (TyNameNameAnn) → ann → TyName → [TyVarDecl TyName NameAnn] → [VarDecl TyName Name uni ann] → Quote [VarDecl TyName Name uni NameAnn] Source #

Establish scoping for all constructors of a data type by establishing scoping for each of them individually. If there are no constructors, then a dummy one is added, because we need to maintain the invariant that every binding is referenced as an in-scope one somewhere and the only place where parameters of a data type can be referenced this way is a constructor of that data type.

establishScopingBinding ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → Binding TyName Name uni fun ann → Quote (Binding TyName Name uni fun NameAnn) Source #

Establish scoping of a binding. Each bindings gets referenced in its own body either as an in-scope or out-of-scope one, which is controlled by the first argument and ultimately depends on the recursivity of the binding.

referenceViaBindings ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → NonEmpty (Binding TyName Name uni fun NameAnn) → NonEmpty (Binding TyName Name uni fun NameAnn) Source #

Reference each binding in the last one apart from itself.

referenceBindingsBothWays ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → NonEmpty (Binding TyName Name uni fun NameAnn) → NonEmpty (Binding TyName Name uni fun NameAnn) Source #

Reference each binding in the first one apart from itself and in the last one also apart from itself. Former bindings are always visible in latter ones and whether latter bindings are visible in former ones is controlled by the first argument and ultimately depends on the recursivity of the family of bindings.

establishScopingBindings ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → NonEmpty (Binding TyName Name uni fun ann) → Quote (NonEmpty (Binding TyName Name uni fun NameAnn)) Source #

Establish scoping for a family of bindings.

registerByRecursivityToScopedName name ⇒ Recursivity → name → NameAnn Source #

Return a registering function depending on the recursivity.

Orphan instances

tyname ~ TyNameReference TyName (VarDecl tyname name uni) Source # 
Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → TyNameVarDecl tyname name uni NameAnnVarDecl tyname name uni NameAnn Source #

tyname ~ TyNameReference TyName (Datatype tyname name uni) Source #

Scoping for data types is hard, so we employ some extra paranoia and reference the provided TyName in the type of every single constructor, and also apply the final head to that TyName.

Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → TyNameDatatype tyname name uni NameAnnDatatype tyname name uni NameAnn Source #

name ~ NameReference Name (Binding tyname name uni fun) Source #

Unlike other Reference instances this one does not guarantee that the name will actually be referenced, but it's too convenient to have this instance to give up on it, without it would be awkward to express "reference this binding in this thing".

Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → NameBinding tyname name uni fun NameAnnBinding tyname name uni fun NameAnn Source #

name ~ NameReference Name (Term tyname name uni fun) Source # 
Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → NameTerm tyname name uni fun NameAnnTerm tyname name uni fun NameAnn Source #

tyname ~ TyNameReference TyName (Binding tyname name uni fun) Source # 
Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → TyNameBinding tyname name uni fun NameAnnBinding tyname name uni fun NameAnn Source #

tyname ~ TyNameReference TyName (Term tyname name uni fun) Source # 
Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → TyNameTerm tyname name uni fun NameAnnTerm tyname name uni fun NameAnn Source #

tyname ~ TyNameCollectScopeInfo (TyVarDecl tyname) Source # 
Instance details

Reference tyname t ⇒ Reference (TyVarDecl tyname ann) t Source # 
Instance details

Methods

referenceVia ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → TyVarDecl tyname ann → t NameAnn → t NameAnn Source #

(tyname ~ TyName, name ~ Name) ⇒ CollectScopeInfo (VarDecl tyname name uni) Source # 
Instance details

Methods

collectScopeInfoVarDecl tyname name uni NameAnnScopeErrorOrInfo Source #

(tyname ~ TyName, name ~ Name) ⇒ CollectScopeInfo (Datatype tyname name uni) Source # 
Instance details

Methods

collectScopeInfoDatatype tyname name uni NameAnnScopeErrorOrInfo Source #

(tyname ~ TyName, name ~ Name) ⇒ CollectScopeInfo (Binding tyname name uni fun) Source # 
Instance details

Methods

collectScopeInfoBinding tyname name uni fun NameAnnScopeErrorOrInfo Source #

(tyname ~ TyName, name ~ Name) ⇒ CollectScopeInfo (Program tyname name uni fun) Source # 
Instance details

Methods

collectScopeInfoProgram tyname name uni fun NameAnnScopeErrorOrInfo Source #

(tyname ~ TyName, name ~ Name) ⇒ CollectScopeInfo (Term tyname name uni fun) Source # 
Instance details

Methods

collectScopeInfoTerm tyname name uni fun NameAnnScopeErrorOrInfo Source #

(tyname ~ TyName, name ~ Name) ⇒ EstablishScoping (Program tyname name uni fun) Source # 
Instance details

Methods

establishScopingProgram tyname name uni fun ann → Quote (Program tyname name uni fun NameAnn) Source #

(tyname ~ TyName, name ~ Name) ⇒ EstablishScoping (Term tyname name uni fun) Source # 
Instance details

Methods

establishScopingTerm tyname name uni fun ann → Quote (Term tyname name uni fun NameAnn) Source #

Reference name t ⇒ Reference (VarDecl tyname name uni ann) t Source # 
Instance details

Methods

referenceVia ∷ (∀ name0. ToScopedName name0 ⇒ name0 → NameAnn) → VarDecl tyname name uni ann → t NameAnn → t NameAnn Source #

(Reference TyName t, Reference Name t) ⇒ Reference (Datatype TyName Name uni ann) t Source # 
Instance details

Methods

referenceVia ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → Datatype TyName Name uni ann → t NameAnn → t NameAnn Source #

(Reference TyName t, Reference Name t) ⇒ Reference (Binding TyName Name uni fun ann) t Source # 
Instance details

Methods

referenceVia ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → Binding TyName Name uni fun ann → t NameAnn → t NameAnn Source #