Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- _nameUnique :: Unique
- isIdentifierStartingChar :: Char -> Bool
- isIdentifierChar :: Char -> Bool
- isQuotedIdentifierChar :: Char -> Bool
- isValidUnquotedName :: Text -> Bool
- toPrintedName :: Text -> Text
- newtype TyName = TyName {}
- data Named a = Named {
- _namedString :: Text
- _namedValue :: a
- newtype Unique = Unique {}
- newtype TypeUnique = TypeUnique {}
- newtype TermUnique = TermUnique {}
- class HasText a where
- class Coercible unique Unique => HasUnique a unique | a -> unique where
- theUnique :: HasUnique name unique => Lens' name Unique
- mapNameString :: (Text -> Text) -> Name -> Name
- mapTyNameString :: (Text -> Text) -> TyName -> TyName
Types
A Name
represents variables/names in Plutus Core.
Name | |
|
Instances
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.
isValidUnquotedName :: Text -> Bool Source #
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.
We use a newtype
to enforce separation between names used for types and
those used for terms.
Instances
Generic TyName Source # | |
Show TyName Source # | |
NFData TyName Source # | |
Defined in PlutusCore.Name.Unique | |
Flat TyName | |
Eq TyName Source # | |
Ord TyName Source # | |
Defined in PlutusCore.Name.Unique | |
Hashable TyName Source # | |
Defined in PlutusCore.Name.Unique | |
Wrapped TyName Source # | |
ToScopedName TyName Source # | |
Defined in PlutusCore.Check.Scoping toScopedName :: TyName -> ScopedName Source # | |
HasText TyName Source # | |
Pretty TyName Source # | |
Defined in PlutusCore.Core.Instance.Pretty.Default | |
HasUnique TyName TypeUnique Source # | |
Defined in PlutusCore.Name.Unique | |
HasPrettyConfigName config => PrettyBy config TyName Source # | |
Defined in PlutusCore.Name.Unique | |
Lift TyName Source # | |
tyname ~ TyName => Reference TyName (Type tyname uni) Source # | |
Defined in PlutusCore.Core.Instance.Scoping 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 # | |
Defined in PlutusCore.Core.Instance.Scoping referenceVia :: (forall name0. ToScopedName name0 => name0 -> NameAnn) -> TyName -> Term tyname name uni fun NameAnn -> Term tyname name uni fun NameAnn Source # | |
Flat (Binder TyName) | |
(GEq uni, Eq ann) => Eq (Type TyName uni ann) Source # | |
TermLike (Term name uni fun) TyName name uni fun Source # | |
Defined in UntypedPlutusCore.Core.Type 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 # | |
Defined in PlutusCore.Error _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 # | |
HasConstant (Term TyName Name uni fun ()) Source # | |
type Rep TyName Source # | |
Defined in PlutusCore.Name.Unique | |
type Unwrapped TyName Source # | |
Defined in PlutusCore.Name.Unique |
Named | |
|
Instances
Foldable Named Source # | |
Defined in PlutusCore.Name.Unique 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 # | |
Traversable Named Source # | |
Functor Named Source # | |
A unique identifier
Instances
Enum Unique Source # | |
Defined in PlutusCore.Name.Unique succ :: Unique -> Unique Source # pred :: Unique -> Unique Source # toEnum :: Int -> Unique Source # fromEnum :: Unique -> Int Source # enumFrom :: Unique -> [Unique] Source # enumFromThen :: Unique -> Unique -> [Unique] Source # enumFromTo :: Unique -> Unique -> [Unique] Source # enumFromThenTo :: Unique -> Unique -> Unique -> [Unique] Source # | |
Show Unique Source # | |
NFData Unique Source # | |
Defined in PlutusCore.Name.Unique | |
Flat Unique | |
Eq Unique Source # | |
Ord Unique Source # | |
Defined in PlutusCore.Name.Unique | |
Hashable Unique Source # | |
Defined in PlutusCore.Name.Unique | |
Pretty Unique Source # | |
Defined in PlutusCore.Name.Unique | |
HasUnique Unique Unique Source # | |
Lift Unique Source # | |
newtype TypeUnique Source #
The unique of a type-level name.
Instances
Eq TypeUnique Source # | |
Defined in PlutusCore.Name.Unique (==) :: TypeUnique -> TypeUnique -> Bool Source # (/=) :: TypeUnique -> TypeUnique -> Bool Source # | |
Ord TypeUnique Source # | |
Defined in PlutusCore.Name.Unique compare :: TypeUnique -> TypeUnique -> Ordering Source # (<) :: TypeUnique -> TypeUnique -> Bool Source # (<=) :: TypeUnique -> TypeUnique -> Bool Source # (>) :: TypeUnique -> TypeUnique -> Bool Source # (>=) :: TypeUnique -> TypeUnique -> Bool Source # max :: TypeUnique -> TypeUnique -> TypeUnique Source # min :: TypeUnique -> TypeUnique -> TypeUnique Source # | |
Hashable TypeUnique Source # | |
Defined in PlutusCore.Name.Unique hashWithSalt :: Int -> TypeUnique -> Int hash :: TypeUnique -> Int | |
HasUnique TyName TypeUnique Source # | |
Defined in PlutusCore.Name.Unique | |
HasRenaming ScopedRenaming TypeUnique Source # | |
Defined in PlutusCore.Rename.Monad | |
HasUnique tyname TypeUnique => HasUnique (TyVarDecl tyname ann) TypeUnique Source # | |
Defined in PlutusCore.Core.Type |
newtype TermUnique Source #
The unique of a term-level name.
Instances
Eq TermUnique Source # | |
Defined in PlutusCore.Name.Unique (==) :: TermUnique -> TermUnique -> Bool Source # (/=) :: TermUnique -> TermUnique -> Bool Source # | |
Ord TermUnique Source # | |
Defined in PlutusCore.Name.Unique compare :: TermUnique -> TermUnique -> Ordering Source # (<) :: TermUnique -> TermUnique -> Bool Source # (<=) :: TermUnique -> TermUnique -> Bool Source # (>) :: TermUnique -> TermUnique -> Bool Source # (>=) :: TermUnique -> TermUnique -> Bool Source # max :: TermUnique -> TermUnique -> TermUnique Source # min :: TermUnique -> TermUnique -> TermUnique Source # | |
Hashable TermUnique Source # | |
Defined in PlutusCore.Name.Unique hashWithSalt :: Int -> TermUnique -> Int hash :: TermUnique -> Int | |
HasUnique Name TermUnique Source # | |
Defined in PlutusCore.Name.Unique | |
HasRenaming ScopedRenaming TermUnique Source # | |
Defined in PlutusCore.Rename.Monad | |
HasUnique name TermUnique => HasUnique (VarDecl tyname name uni ann) TermUnique Source # | |
Defined in PlutusCore.Core.Type |
class Coercible unique Unique => HasUnique a unique | a -> unique where Source #
Types which have a Unique
attached to them, mostly names.
Nothing
Instances
HasUnique Name TermUnique Source # | |
Defined in PlutusCore.Name.Unique | |
HasUnique TyName TypeUnique Source # | |
Defined in PlutusCore.Name.Unique | |
HasUnique Unique Unique Source # | |
HasUnique tyname TypeUnique => HasUnique (TyVarDecl tyname ann) TypeUnique Source # | |
Defined in PlutusCore.Core.Type | |
HasUnique name TermUnique => HasUnique (VarDecl tyname name uni ann) TermUnique Source # | |
Defined in PlutusCore.Core.Type |
theUnique :: HasUnique name unique => Lens' name Unique Source #
A lens focused on the Unique
of a name.