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

PlutusCore.Name.Unique

Description

A Name is a datatype used to identify a variable inside the Plutus Core languages. Name comparisons are a fundamental part of the domain logic, and comparing Text directly is inefficient. As a solution to this problem, we provide the Unique type which is an integer associated to the Name, unique to each instantiation of the type. We can, therefore, compare the integers instead, which is obviously much more cost-effective.

We distinguish between the names of term variables and type variables by defining the TyName wrapper over Name. Since the code we usually write is polymorphic in the name type, we want to be able to define a class of names which have an associated Unique. This class is HasUnique, see the definition below.

Synopsis

Types

data Name Source #

A Name represents variables/names in Plutus Core.

Constructors

Name 

Fields

Instances

Instances details
Generic Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Associated Types

type Rep NameTypeType Source #

Methods

fromNameRep Name x Source #

toRep Name x → Name Source #

Show Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

showsPrecIntNameShowS Source #

showNameString Source #

showList ∷ [Name] → ShowS Source #

NFData Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

rnfName → () Source #

Flat Name Source # 
Instance details

Defined in PlutusCore.Flat

Eq Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

(==)NameNameBool Source #

(/=)NameNameBool Source #

Ord Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

compareNameNameOrdering Source #

(<)NameNameBool Source #

(<=)NameNameBool Source #

(>)NameNameBool Source #

(>=)NameNameBool Source #

maxNameNameName Source #

minNameNameName Source #

Hashable Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

hashWithSaltIntNameInt Source #

hashNameInt Source #

ToScopedName Name Source # 
Instance details

Defined in PlutusCore.Check.Scoping

HasText Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Pretty Name Source # 
Instance details

Defined in PlutusCore.Core.Instance.Pretty.Default

Methods

prettyNameDoc ann Source #

prettyList ∷ [Name] → Doc ann Source #

HasUnique Name TermUnique Source # 
Instance details

Defined in PlutusCore.Name.Unique

HasPrettyConfigName config ⇒ PrettyBy config Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

prettyBy ∷ config → NameDoc ann Source #

prettyListBy ∷ config → [Name] → Doc ann Source #

Lift Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

liftQuote m ⇒ Name → m Exp Source #

liftTyped ∷ ∀ (m ∷ TypeType). Quote m ⇒ NameCode m Name Source #

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

Defined in PlutusCore.Core.Instance.Scoping

Methods

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

Flat (Binder Name) Source # 
Instance details

Defined in PlutusCore.Flat

AsTypeError (Error uni fun ann) (Term TyName Name uni fun ()) uni fun ann Source # 
Instance details

Defined in PlutusCore.Error

Methods

_TypeError ∷ Prism' (Error uni fun ann) (TypeError (Term TyName Name uni fun ()) uni fun ann) Source #

_KindMismatch ∷ Prism' (Error uni fun ann) (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source #

_TypeMismatch ∷ Prism' (Error uni fun ann) (ann, Term TyName Name uni fun (), ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source #

_TyNameMismatch ∷ Prism' (Error uni fun ann) (ann, TyName, TyName) Source #

_NameMismatch ∷ Prism' (Error uni fun ann) (ann, Name, Name) Source #

_FreeTypeVariableE ∷ Prism' (Error uni fun ann) (ann, TyName) Source #

_FreeVariableE ∷ Prism' (Error uni fun ann) (ann, Name) Source #

_UnknownBuiltinFunctionE ∷ Prism' (Error uni fun ann) (ann, fun) Source #

(GEq uni, Closed uni, Everywhere uni Eq, Eq fun, Eq ann) ⇒ Eq (Term Name uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Core.Instance.Eq

Methods

(==)Term Name uni fun ann → Term Name uni fun ann → Bool Source #

(/=)Term Name uni fun ann → Term Name uni fun ann → Bool Source #

HashableTermConstraints uni fun ann ⇒ Hashable (Term Name uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Core.Instance.Eq

Methods

hashWithSaltIntTerm Name uni fun ann → Int Source #

hashTerm Name uni fun ann → Int Source #

(GEq uni, Closed uni, Everywhere uni Eq, Eq fun, Eq ann) ⇒ Eq (Term TyName Name uni fun ann) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

Methods

(==)Term TyName Name uni fun ann → Term TyName Name uni fun ann → Bool Source #

(/=)Term TyName Name uni fun ann → Term TyName Name uni fun ann → Bool Source #

HasConstant (Term TyName Name uni fun ()) Source # 
Instance details

Defined in PlutusCore.Builtin.HasConstant

Methods

asConstantTerm TyName Name uni fun () → Either BuiltinError (Some (ValueOf (UniOf (Term TyName Name uni fun ())))) Source #

fromConstantSome (ValueOf (UniOf (Term TyName Name uni fun ()))) → Term TyName Name uni fun () Source #

type Rep Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

type Rep Name = D1 ('MetaData "Name" "PlutusCore.Name.Unique" "plutus-core-1.36.0.0-inplace" 'False) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "_nameText") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "_nameUnique") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Unique)))

isIdentifierStartingCharCharBool Source #

Allowed characters in the starting position of a non-quoted identifier.

isIdentifierCharCharBool Source #

Allowed characters in a non-starting position of a non-quoted identifier.

isQuotedIdentifierCharCharBool Source #

Allowed characters in a quoted identifier.

toPrintedNameTextText Source #

Quote the name with backticks if it is not a valid unquoted name. It does not check whether the given name is a valid quoted name.

newtype TyName Source #

We use a newtype to enforce separation between names used for types and those used for terms.

Constructors

TyName 

Fields

Instances

Instances details
Generic TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Associated Types

type Rep TyNameTypeType Source #

Methods

fromTyNameRep TyName x Source #

toRep TyName x → TyName Source #

Show TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

NFData TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

rnfTyName → () Source #

Flat TyName Source # 
Instance details

Defined in PlutusCore.Flat

Eq TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

(==)TyNameTyNameBool Source #

(/=)TyNameTyNameBool Source #

Ord TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Hashable TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

hashWithSaltIntTyNameInt Source #

hashTyNameInt Source #

Wrapped TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Associated Types

type Unwrapped TyName

Methods

_Wrapped' ∷ Iso' TyName (Unwrapped TyName)

ToScopedName TyName Source # 
Instance details

Defined in PlutusCore.Check.Scoping

HasText TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Pretty TyName Source # 
Instance details

Defined in PlutusCore.Core.Instance.Pretty.Default

Methods

prettyTyNameDoc ann Source #

prettyList ∷ [TyName] → Doc ann Source #

HasUnique TyName TypeUnique Source # 
Instance details

Defined in PlutusCore.Name.Unique

HasPrettyConfigName config ⇒ PrettyBy config TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

prettyBy ∷ config → TyNameDoc ann Source #

prettyListBy ∷ config → [TyName] → Doc ann Source #

Lift TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

liftQuote m ⇒ TyName → m Exp Source #

liftTyped ∷ ∀ (m ∷ TypeType). Quote m ⇒ TyNameCode m TyName Source #

tyname ~ TyNameReference TyName (Type tyname uni) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Scoping

Methods

referenceVia ∷ (∀ name. ToScopedName name ⇒ name → NameAnn) → TyNameType tyname uni NameAnnType tyname uni NameAnn Source #

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

Defined in PlutusCore.Core.Instance.Scoping

Methods

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

Flat (Binder TyName) Source # 
Instance details

Defined in PlutusCore.Flat

(GEq uni, Eq ann) ⇒ Eq (Type TyName uni ann) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

Methods

(==)Type TyName uni ann → Type TyName uni ann → Bool Source #

(/=)Type TyName uni ann → Type TyName uni ann → Bool Source #

TermLike (Term name uni fun) TyName name uni fun Source # 
Instance details

Defined in UntypedPlutusCore.Core.Type

Methods

var ∷ ann → name → Term name uni fun ann Source #

tyAbs ∷ ann → TyNameKind ann → Term name uni fun ann → Term name uni fun ann Source #

lamAbs ∷ ann → name → Type TyName uni ann → Term name uni fun ann → Term name uni fun ann Source #

apply ∷ ann → Term name uni fun ann → Term name uni fun ann → Term name uni fun ann Source #

constant ∷ ann → Some (ValueOf uni) → Term name uni fun ann Source #

builtin ∷ ann → fun → Term name uni fun ann Source #

tyInst ∷ ann → Term name uni fun ann → Type TyName uni ann → Term name uni fun ann Source #

unwrap ∷ ann → Term name uni fun ann → Term name uni fun ann Source #

iWrap ∷ ann → Type TyName uni ann → Type TyName uni ann → Term name uni fun ann → Term name uni fun ann Source #

error ∷ ann → Type TyName uni ann → Term name uni fun ann Source #

constr ∷ ann → Type TyName uni ann → Word64 → [Term name uni fun ann] → Term name uni fun ann Source #

kase ∷ ann → Type TyName uni ann → Term name uni fun ann → [Term name uni fun ann] → Term name uni fun ann Source #

termLet ∷ ann → TermDef (Term name uni fun) TyName name uni ann → Term name uni fun ann → Term name uni fun ann Source #

typeLet ∷ ann → TypeDef TyName uni ann → Term name uni fun ann → Term name uni fun ann Source #

AsTypeError (Error uni fun ann) (Term TyName Name uni fun ()) uni fun ann Source # 
Instance details

Defined in PlutusCore.Error

Methods

_TypeError ∷ Prism' (Error uni fun ann) (TypeError (Term TyName Name uni fun ()) uni fun ann) Source #

_KindMismatch ∷ Prism' (Error uni fun ann) (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source #

_TypeMismatch ∷ Prism' (Error uni fun ann) (ann, Term TyName Name uni fun (), ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source #

_TyNameMismatch ∷ Prism' (Error uni fun ann) (ann, TyName, TyName) Source #

_NameMismatch ∷ Prism' (Error uni fun ann) (ann, Name, Name) Source #

_FreeTypeVariableE ∷ Prism' (Error uni fun ann) (ann, TyName) Source #

_FreeVariableE ∷ Prism' (Error uni fun ann) (ann, Name) Source #

_UnknownBuiltinFunctionE ∷ Prism' (Error uni fun ann) (ann, fun) Source #

(GEq uni, Closed uni, Everywhere uni Eq, Eq fun, Eq ann) ⇒ Eq (Term TyName Name uni fun ann) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

Methods

(==)Term TyName Name uni fun ann → Term TyName Name uni fun ann → Bool Source #

(/=)Term TyName Name uni fun ann → Term TyName Name uni fun ann → Bool Source #

HasConstant (Term TyName Name uni fun ()) Source # 
Instance details

Defined in PlutusCore.Builtin.HasConstant

Methods

asConstantTerm TyName Name uni fun () → Either BuiltinError (Some (ValueOf (UniOf (Term TyName Name uni fun ())))) Source #

fromConstantSome (ValueOf (UniOf (Term TyName Name uni fun ()))) → Term TyName Name uni fun () Source #

type Rep TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

type Rep TyName = D1 ('MetaData "TyName" "PlutusCore.Name.Unique" "plutus-core-1.36.0.0-inplace" 'True) (C1 ('MetaCons "TyName" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTyName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name)))
type Unwrapped TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

type Unwrapped TyName = GUnwrapped (Rep TyName)

data Named a Source #

Constructors

Named 

Fields

Instances

Instances details
Foldable Named Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

foldMonoid m ⇒ Named m → m Source #

foldMapMonoid m ⇒ (a → m) → Named a → m Source #

foldMap'Monoid m ⇒ (a → m) → Named a → m Source #

foldr ∷ (a → b → b) → b → Named a → b Source #

foldr' ∷ (a → b → b) → b → Named a → b Source #

foldl ∷ (b → a → b) → b → Named a → b Source #

foldl' ∷ (b → a → b) → b → Named a → b Source #

foldr1 ∷ (a → a → a) → Named a → a Source #

foldl1 ∷ (a → a → a) → Named a → a Source #

toListNamed a → [a] Source #

nullNamed a → Bool Source #

lengthNamed a → Int Source #

elemEq a ⇒ a → Named a → Bool Source #

maximumOrd a ⇒ Named a → a Source #

minimumOrd a ⇒ Named a → a Source #

sumNum a ⇒ Named a → a Source #

productNum a ⇒ Named a → a Source #

Traversable Named Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

traverseApplicative f ⇒ (a → f b) → Named a → f (Named b) Source #

sequenceAApplicative f ⇒ Named (f a) → f (Named a) Source #

mapMMonad m ⇒ (a → m b) → Named a → m (Named b) Source #

sequenceMonad m ⇒ Named (m a) → m (Named a) Source #

Functor Named Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

fmap ∷ (a → b) → Named a → Named b Source #

(<$) ∷ a → Named b → Named a Source #

newtype Unique Source #

A unique identifier

Constructors

Unique 

Fields

Instances

Instances details
Enum Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Show Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

NFData Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

rnfUnique → () Source #

Flat Unique Source # 
Instance details

Defined in PlutusCore.Flat

Eq Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

(==)UniqueUniqueBool Source #

(/=)UniqueUniqueBool Source #

Ord Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Hashable Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

hashWithSaltIntUniqueInt Source #

hashUniqueInt Source #

Pretty Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

prettyUniqueDoc ann Source #

prettyList ∷ [Unique] → Doc ann Source #

HasUnique Unique Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Lift Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

liftQuote m ⇒ Unique → m Exp Source #

liftTyped ∷ ∀ (m ∷ TypeType). Quote m ⇒ UniqueCode m Unique Source #

newtype TypeUnique Source #

The unique of a type-level name.

Constructors

TypeUnique 

Fields

newtype TermUnique Source #

The unique of a term-level name.

Constructors

TermUnique 

Fields

class HasText a where Source #

Types which have a textual name attached to them.

Methods

theTextLens' a Text Source #

Instances

Instances details
HasText Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

HasText TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

class Coercible unique UniqueHasUnique a unique | a → unique where Source #

Types which have a Unique attached to them, mostly names.

Minimal complete definition

Nothing

Methods

uniqueLens' a unique Source #

default unique ∷ (Wrapped a, HasUnique (Unwrapped a) unique', Coercible unique' unique) ⇒ Lens' a unique Source #

Instances

Instances details
HasUnique Name TermUnique Source # 
Instance details

Defined in PlutusCore.Name.Unique

HasUnique TyName TypeUnique Source # 
Instance details

Defined in PlutusCore.Name.Unique

HasUnique Unique Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

HasUnique name unique ⇒ HasUnique (LR name) (LR unique) Source # 
Instance details

Defined in PlutusCore.Eq

Methods

uniqueLens' (LR name) (LR unique) Source #

HasUnique name unique ⇒ HasUnique (RL name) (RL unique) Source # 
Instance details

Defined in PlutusCore.Eq

Methods

uniqueLens' (RL name) (RL unique) Source #

HasUnique tyname TypeUniqueHasUnique (TyVarDecl tyname ann) TypeUnique Source # 
Instance details

Defined in PlutusCore.Core.Type

Methods

uniqueLens' (TyVarDecl tyname ann) TypeUnique Source #

HasUnique name TermUniqueHasUnique (VarDecl tyname name uni ann) TermUnique Source # 
Instance details

Defined in PlutusCore.Core.Type

Methods

uniqueLens' (VarDecl tyname name uni ann) TermUnique Source #

theUniqueHasUnique name unique ⇒ Lens' name Unique Source #

A lens focused on the Unique of a name.

Functions

mapNameString ∷ (TextText) → NameName Source #

Apply a function to the string representation of a Name.

mapTyNameString ∷ (TextText) → TyNameTyName Source #

Apply a function to the string representation of a TyName.