plutus-core-1.60.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
  • data Name = Name {
    • _nameText :: Text #

      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 #

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 # 
Instance details

Defined in PlutusCore.Name.Unique

Associated Types

type Text

 
  • _namedValue :: a
     
  • Instances

    Instances details
    Foldable Named # 
    Instance details

    Defined in PlutusCore.Name.Unique

    Methods

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

    foldMap :: Monoid m => (a -> m) -> Named a -> m #

    foldMap' :: Monoid m => (a -> m) -> Named a -> m #

    foldr :: (a -> b -> b) -> b -> Named a -> b #

    foldr' :: (a -> b -> b) -> b -> Named a -> b #

    foldl :: (b -> a -> b) -> b -> Named a -> b #

    foldl' :: (b -> a -> b) -> b -> Named a -> b #

    foldr1 :: (a -> a -> a) -> Named a -> a #

    foldl1 :: (a -> a -> a) -> Named a -> a #

    toList :: Named a -> [a] #

    null :: Named a -> Bool #

    length :: Named a -> Int #

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

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

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

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

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

    Traversable Named # 
    Instance details

    Defined in PlutusCore.Name.Unique

    Methods

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

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

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

    sequence :: Monad m => Named (m a) -> m (Named a) #

    Functor Named # 
    Instance details

    Defined in PlutusCore.Name.Unique

    Methods

    fmap :: (a -> b) -> Named a -> Named b #

    (<$) :: a -> Named b -> Named a #

    newtype Unique #

    A unique identifier This is normally a positive integral number, except in topUnique where we make use of a negative unique to signify top-level.

    Constructors

    Unique 

    Fields