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 Name :: Type -> Type Source #

Methods

from :: Name -> Rep Name x Source #

to :: Rep Name x -> Name Source #

Show Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

NFData Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

rnf :: Name -> () Source #

Flat Name 
Instance details

Defined in PlutusCore.Flat

Methods

encode :: Name -> Encoding

decode :: Get Name

size :: Name -> NumBits -> NumBits

Eq Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

(==) :: Name -> Name -> Bool Source #

(/=) :: Name -> Name -> Bool Source #

Ord Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Hashable Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

hashWithSalt :: Int -> Name -> Int

hash :: Name -> Int

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

pretty :: Name -> Doc ann #

prettyList :: [Name] -> Doc ann #

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 -> Name -> Doc ann #

prettyListBy :: config -> [Name] -> Doc ann #

Lift Name Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

lift :: Quote m => Name -> m Exp Source #

liftTyped :: forall (m :: Type -> Type). Quote m => Name -> Code m Name Source #

name ~ Name => Reference Name (Term tyname name uni fun) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Scoping

Methods

referenceVia :: (forall name0. ToScopedName name0 => name0 -> NameAnn) -> Name -> Term tyname name uni fun NameAnn -> Term tyname name uni fun NameAnn Source #

Flat (Binder Name) 
Instance details

Defined in PlutusCore.Flat

Methods

encode :: Binder Name -> Encoding

decode :: Get (Binder Name)

size :: Binder Name -> NumBits -> NumBits

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

hashWithSalt :: Int -> Term Name uni fun ann -> Int

hash :: Term Name uni fun ann -> Int

(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

asConstant :: Term TyName Name uni fun () -> Either BuiltinError (Some (ValueOf (UniOf (Term TyName Name uni fun ())))) Source #

fromConstant :: Some (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-7ehJj5tIPqoJIiiivXkX9N" 'False) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "_nameText") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "_nameUnique") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Unique)))

isIdentifierStartingChar :: Char -> Bool Source #

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

isIdentifierChar :: Char -> Bool Source #

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

isQuotedIdentifierChar :: Char -> Bool Source #

Allowed characters in a quoted identifier.

toPrintedName :: Text -> Text 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 TyName :: Type -> Type Source #

Show TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

NFData TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

rnf :: TyName -> () Source #

Flat TyName 
Instance details

Defined in PlutusCore.Flat

Methods

encode :: TyName -> Encoding

decode :: Get TyName

size :: TyName -> NumBits -> NumBits

Eq TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Ord TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Hashable TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

hashWithSalt :: Int -> TyName -> Int

hash :: TyName -> Int

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

pretty :: TyName -> Doc ann #

prettyList :: [TyName] -> Doc ann #

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 -> TyName -> Doc ann #

prettyListBy :: config -> [TyName] -> Doc ann #

Lift TyName Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

lift :: Quote m => TyName -> m Exp Source #

liftTyped :: forall (m :: Type -> Type). Quote m => TyName -> Code m TyName Source #

tyname ~ TyName => Reference TyName (Type tyname uni) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Scoping

Methods

referenceVia :: (forall name. ToScopedName name => name -> NameAnn) -> TyName -> Type tyname uni NameAnn -> Type tyname uni NameAnn Source #

tyname ~ TyName => Reference TyName (Term tyname name uni fun) Source # 
Instance details

Defined in PlutusCore.Core.Instance.Scoping

Methods

referenceVia :: (forall name0. ToScopedName name0 => name0 -> NameAnn) -> TyName -> Term tyname name uni fun NameAnn -> Term tyname name uni fun NameAnn Source #

Flat (Binder TyName) 
Instance details

Defined in PlutusCore.Flat

Methods

encode :: Binder TyName -> Encoding

decode :: Get (Binder TyName)

size :: Binder TyName -> NumBits -> NumBits

(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 -> TyName -> Kind 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

asConstant :: Term TyName Name uni fun () -> Either BuiltinError (Some (ValueOf (UniOf (Term TyName Name uni fun ())))) Source #

fromConstant :: Some (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-7ehJj5tIPqoJIiiivXkX9N" '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

fold :: Monoid m => Named m -> m Source #

foldMap :: Monoid 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 #

toList :: Named a -> [a] Source #

null :: Named a -> Bool Source #

length :: Named a -> Int Source #

elem :: Eq a => a -> Named a -> Bool Source #

maximum :: Ord a => Named a -> a Source #

minimum :: Ord a => Named a -> a Source #

sum :: Num a => Named a -> a Source #

product :: Num a => Named a -> a Source #

Traversable Named Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

traverse :: Applicative f => (a -> f b) -> Named a -> f (Named b) Source #

sequenceA :: Applicative f => Named (f a) -> f (Named a) Source #

mapM :: Monad m => (a -> m b) -> Named a -> m (Named b) Source #

sequence :: Monad 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

rnf :: Unique -> () Source #

Flat Unique 
Instance details

Defined in PlutusCore.Flat

Methods

encode :: Unique -> Encoding

decode :: Get Unique

size :: Unique -> NumBits -> NumBits

Eq Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Ord Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Hashable Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

hashWithSalt :: Int -> Unique -> Int

hash :: Unique -> Int

Pretty Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

pretty :: Unique -> Doc ann #

prettyList :: [Unique] -> Doc ann #

HasUnique Unique Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Lift Unique Source # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

lift :: Quote m => Unique -> m Exp Source #

liftTyped :: forall (m :: Type -> Type). Quote m => Unique -> Code m Unique Source #

class HasText a where Source #

Types which have a textual name attached to them.

Methods

theText :: Lens' 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 Unique => HasUnique a unique | a -> unique where Source #

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

Minimal complete definition

Nothing

Methods

unique :: Lens' 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 tyname TypeUnique => HasUnique (TyVarDecl tyname ann) TypeUnique Source # 
Instance details

Defined in PlutusCore.Core.Type

Methods

unique :: Lens' (TyVarDecl tyname ann) TypeUnique Source #

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

Defined in PlutusCore.Core.Type

Methods

unique :: Lens' (VarDecl tyname name uni ann) TermUnique Source #

theUnique :: HasUnique name unique => Lens' name Unique Source #

A lens focused on the Unique of a name.

Functions

mapNameString :: (Text -> Text) -> Name -> Name Source #

Apply a function to the string representation of a Name.

mapTyNameString :: (Text -> Text) -> TyName -> TyName Source #

Apply a function to the string representation of a TyName.