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

PlutusCore.Builtin

Description

Reexports from modules from the Builtin folder.

Synopsis

Documentation

class Typeable (a :: k) Source #

The class Typeable allows a concrete representation of a type to be calculated.

Minimal complete definition

typeRep#

data TypeScheme val (args :: [Type]) res where Source #

The type of type schemes of built-in functions. args is a list of types of arguments, res is the resulting type. E.g. Text -> Bool -> Integer is encoded as TypeScheme val [Text, Bool] Integer.

Constructors

TypeSchemeResult :: (Typeable res, KnownTypeAst TyName (UniOf val) res, MakeKnown val res) => TypeScheme val '[] res 
TypeSchemeArrow :: (Typeable arg, KnownTypeAst TyName (UniOf val) arg, MakeKnown val arg, ReadKnown val arg) => TypeScheme val args res -> TypeScheme val (arg ': args) res infixr 9 
TypeSchemeAll :: (KnownSymbol text, KnownNat uniq, KnownKind kind) => Proxy '(text, uniq, kind) -> TypeScheme val args res -> TypeScheme val args res 

Instances

Instances details
Show (TypeScheme val args res) Source # 
Instance details

Defined in PlutusCore.Builtin.TypeScheme

Methods

showsPrec :: Int -> TypeScheme val args res -> ShowS Source #

show :: TypeScheme val args res -> String Source #

showList :: [TypeScheme val args res] -> ShowS Source #

argProxy :: TypeScheme val (arg ': args) res -> Proxy arg Source #

typeSchemeToType :: TypeScheme val args res -> Type TyName (UniOf val) () Source #

Convert a TypeScheme to the corresponding Kind.

class (uni `Everywhere` ImplementedKnownTypeAst uni, uni `Everywhere` ImplementedReadKnownIn uni, uni `Everywhere` ImplementedMakeKnownIn uni) => TestTypesFromTheUniverseAreAllKnown uni Source #

An instance of this class not having any constraints ensures that every type (according to Everywhere) from the universe has 'KnownTypeAst, ReadKnownIn and MakeKnownIn instances.

Instances

Instances details
TestTypesFromTheUniverseAreAllKnown DefaultUni Source # 
Instance details

Defined in PlutusCore.Default.Universe

data BuiltinRuntime val Source #

A BuiltinRuntime represents a possibly partial builtin application, including an empty builtin application (i.e. just the builtin with no arguments).

Applying or type-instantiating a builtin peels off the corresponding constructor from its BuiltinRuntime.

BuiltinCostedResult contains the cost (an ExBudget) and the result (a BuiltinResult val) of the builtin application. The cost is stored strictly, since the evaluator is going to look at it and the result is stored lazily, since it's not supposed to be forced before accounting for the cost of the application. If the cost exceeds the available budget, the evaluator discards the result of the builtin application without ever forcing it and terminates with evaluation failure. Allowing the user to compute something that they don't have the budget for would be a major bug.

Evaluators that ignore the entire concept of costing (e.g. the CK machine) may of course force the result of the builtin application unconditionally.

Instances

Instances details
Show (BuiltinRuntime (CkValue uni fun)) Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

Show (BuiltinRuntime (CekValue uni fun ann)) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

showsPrec :: Int -> BuiltinRuntime (CekValue uni fun ann) -> ShowS Source #

show :: BuiltinRuntime (CekValue uni fun ann) -> String Source #

showList :: [BuiltinRuntime (CekValue uni fun ann)] -> ShowS Source #

NFData (BuiltinRuntime val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

rnf :: BuiltinRuntime val -> () Source #

NoThunks (BuiltinRuntime val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

noThunks :: Context -> BuiltinRuntime val -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> BuiltinRuntime val -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy (BuiltinRuntime val) -> String

data BuiltinsRuntime fun val Source #

A data wrapper around a function returning the BuiltinRuntime of a built-in function. We use data rather than newtype, because GHC is able to see through newtypes and may break carefully set up optimizations, see https://github.com/IntersectMBO/plutus/pull/4914#issuecomment-1396306606

Using data may make things more expensive, however it was verified at the time of writing that the wrapper is removed before the CEK machine starts, leaving the stored function to be used directly.

In order for lookups to be efficient the BuiltinRuntimes need to be cached, i.e. pulled out of the function statically. See makeBuiltinMeaning for how we achieve that.

Constructors

BuiltinsRuntime 

Fields

Instances

Instances details
(Bounded fun, Enum fun) => NFData (BuiltinsRuntime fun val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

rnf :: BuiltinsRuntime fun val -> () Source #

(Bounded fun, Enum fun) => NoThunks (BuiltinsRuntime fun val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

noThunks :: Context -> BuiltinsRuntime fun val -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> BuiltinsRuntime fun val -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy (BuiltinsRuntime fun val) -> String

lookupBuiltin :: fun -> BuiltinsRuntime fun val -> BuiltinRuntime val Source #

Look up the runtime info of a built-in function during evaluation.

data EvaluationError structural operational Source #

The type of errors that can occur during evaluation. There are two kinds of errors:

  1. Structural ones -- these are errors that are indicative of the _structure_ of the program being wrong. For example, a free variable was encountered during evaluation, a non-function was applied to an argument or tailList was applied to a non-list.
  2. Operational ones -- these are errors that are indicative of the _logic_ of the program being wrong. For example, error was executed, tailList was applied to an empty list or evaluation ran out of gas.

On the chain both of these are just regular failures and we don't distinguish between them there: if a script fails, it fails, it doesn't matter what the reason was. However in the tests it does matter why the failure occurred: a structural error may indicate that the test was written incorrectly while an operational error may be entirely expected.

In other words, structural errors are "runtime type errors" and operational errors are regular runtime errors. Which means that evaluating an (erased) well-typed program should never produce a structural error, only an operational one. This creates a sort of "runtime type system" for UPLC and it would be great to stick to it and enforce in tests etc, but we currently don't.

Constructors

StructuralEvaluationError !structural 
OperationalEvaluationError !operational 

Instances

Instances details
Bifoldable EvaluationError Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

bifold :: Monoid m => EvaluationError m m -> m Source #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> EvaluationError a b -> m Source #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> EvaluationError a b -> c Source #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> EvaluationError a b -> c Source #

Bifunctor EvaluationError Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

bimap :: (a -> b) -> (c -> d) -> EvaluationError a c -> EvaluationError b d Source #

first :: (a -> b) -> EvaluationError a c -> EvaluationError b c Source #

second :: (b -> c) -> EvaluationError a b -> EvaluationError a c Source #

Bitraversable EvaluationError Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> EvaluationError a b -> f (EvaluationError c d) Source #

(HasPrettyDefaults config ~ 'True, PrettyBy config structural, Pretty operational) => PrettyBy config (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

prettyBy :: config -> EvaluationError structural operational -> Doc ann #

prettyListBy :: config -> [EvaluationError structural operational] -> Doc ann #

Functor (EvaluationError structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

fmap :: (a -> b) -> EvaluationError structural a -> EvaluationError structural b Source #

(<$) :: a -> EvaluationError structural b -> EvaluationError structural a Source #

Generic (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Associated Types

type Rep (EvaluationError structural operational) :: Type -> Type Source #

Methods

from :: EvaluationError structural operational -> Rep (EvaluationError structural operational) x Source #

to :: Rep (EvaluationError structural operational) x -> EvaluationError structural operational Source #

(Show structural, Show operational) => Show (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

showsPrec :: Int -> EvaluationError structural operational -> ShowS Source #

show :: EvaluationError structural operational -> String Source #

showList :: [EvaluationError structural operational] -> ShowS Source #

(NFData structural, NFData operational) => NFData (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

rnf :: EvaluationError structural operational -> () Source #

(Eq structural, Eq operational) => Eq (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

(==) :: EvaluationError structural operational -> EvaluationError structural operational -> Bool Source #

(/=) :: EvaluationError structural operational -> EvaluationError structural operational -> Bool Source #

(AsUnliftingError structural, AsUnliftingError operational) => AsUnliftingEvaluationError (EvaluationError structural operational) Source #

An UnliftingEvaluationError is an EvaluationError, hence for this instance we only require both structural and operational to have _UnliftingError prisms, so that we can handle both the cases pointwisely.

Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure operational => AsEvaluationFailure (EvaluationError structural operational) Source #

A raw evaluation failure is always an operational error.

Instance details

Defined in PlutusCore.Evaluation.Error

Methods

_EvaluationFailure :: Prism' (EvaluationError structural operational) () Source #

(Pretty structural, Pretty operational) => Pretty (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

pretty :: EvaluationError structural operational -> Doc ann #

prettyList :: [EvaluationError structural operational] -> Doc ann #

structural ~ MachineError fun => AsMachineError (EvaluationError structural operational) fun Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Exception

Methods

_MachineError :: Prism' (EvaluationError structural operational) (MachineError fun) Source #

_NonPolymorphicInstantiationMachineError :: Prism' (EvaluationError structural operational) () Source #

_NonWrapUnwrappedMachineError :: Prism' (EvaluationError structural operational) () Source #

_NonFunctionalApplicationMachineError :: Prism' (EvaluationError structural operational) () Source #

_OpenTermEvaluatedMachineError :: Prism' (EvaluationError structural operational) () Source #

_UnliftingMachineError :: Prism' (EvaluationError structural operational) UnliftingError Source #

_BuiltinTermArgumentExpectedMachineError :: Prism' (EvaluationError structural operational) () Source #

_UnexpectedBuiltinTermArgumentMachineError :: Prism' (EvaluationError structural operational) () Source #

_NonConstrScrutinized :: Prism' (EvaluationError structural operational) () Source #

_MissingCaseBranch :: Prism' (EvaluationError structural operational) Word64 Source #

AsEvaluationError (EvaluationError structural operational) structural operational Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

_EvaluationError :: Prism' (EvaluationError structural operational) (EvaluationError structural operational) Source #

_StructuralEvaluationError :: Prism' (EvaluationError structural operational) structural Source #

_OperationalEvaluationError :: Prism' (EvaluationError structural operational) operational Source #

ThrowableBuiltins uni fun => MonadError (CekEvaluationException NamedDeBruijn uni fun) (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

throwError :: CekEvaluationException NamedDeBruijn uni fun -> CekM uni fun s a Source #

catchError :: CekM uni fun s a -> (CekEvaluationException NamedDeBruijn uni fun -> CekM uni fun s a) -> CekM uni fun s a Source #

type Rep (EvaluationError structural operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

type Rep (EvaluationError structural operational) = D1 ('MetaData "EvaluationError" "PlutusCore.Evaluation.Error" "plutus-core-1.36.0.0-7ehJj5tIPqoJIiiivXkX9N" 'False) (C1 ('MetaCons "StructuralEvaluationError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 structural)) :+: C1 ('MetaCons "OperationalEvaluationError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 operational)))

class AsEvaluationError r structural operational | r -> structural operational where Source #

Minimal complete definition

_EvaluationError

Methods

_EvaluationError :: Prism' r (EvaluationError structural operational) Source #

_StructuralEvaluationError :: Prism' r structural Source #

_OperationalEvaluationError :: Prism' r operational Source #

Instances

Instances details
AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationError (EvaluationError structural operational) structural operational Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

_EvaluationError :: Prism' (EvaluationError structural operational) (EvaluationError structural operational) Source #

_StructuralEvaluationError :: Prism' (EvaluationError structural operational) structural Source #

_OperationalEvaluationError :: Prism' (EvaluationError structural operational) operational Source #

newtype UnliftingError Source #

The error message part of an UnliftingEvaluationError.

Constructors

MkUnliftingError 

Instances

Instances details
IsString UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Monoid UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Semigroup UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Show UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

NFData UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

rnf :: UnliftingError -> () Source #

Eq UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsUnliftingError UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Pretty UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

pretty :: UnliftingError -> Doc ann #

prettyList :: [UnliftingError] -> Doc ann #

AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

newtype UnliftingEvaluationError Source #

When unlifting of a PLC term into a Haskell value fails, this error is thrown.

Instances

Instances details
Show UnliftingEvaluationError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

NFData UnliftingEvaluationError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Eq UnliftingEvaluationError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsUnliftingEvaluationError UnliftingEvaluationError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Pretty UnliftingEvaluationError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

data BuiltinError Source #

The type of errors that readKnown and makeKnown can return.

Instances

Instances details
Show BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Eq BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsBuiltinError BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsUnliftingEvaluationError BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Pretty BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

pretty :: BuiltinError -> Doc ann #

prettyList :: [BuiltinError] -> Doc ann #

MonadError BuiltinError BuiltinResult Source #

throwError puts every operational unlifting error into the BuiltinFailure logs. This is to compensate for the historical lack of error message content in operational errors (structural ones don't have this problem) in our evaluators (the CK and CEK machines). It would be better to fix the underlying issue and allow operational evaluation errors to carry some form of content, but for now we just fix the symptom in order for the end user to see the error message that they are supposed to see. The fix even makes some sense: what we do here is we emulate logging when the thrown unlifting error is an operational one, i.e. this is similar to what some builtins do manually (like when a crypto builtin fails and puts info about the failure into the logs).

Instance details

Defined in PlutusCore.Builtin.Result

data BuiltinResult a Source #

The monad that makeKnown runs in. Equivalent to ExceptT BuiltinError (Writer (DList Text)), except optimized in two ways:

  1. everything is strict
  2. has the BuiltinSuccess constructor that is used for returning a value with no logs attached, which is the most common case for us, so it helps a lot not to construct and deconstruct a redundant tuple

Moving from ExceptT BuiltinError (Writer (DList Text)) to this data type gave us a speedup of 8% of total evaluation time.

Logs are represented as a DList, because we don't particularly care about the efficiency of logging, since there's no logging on the chain and builtins don't emit much anyway. Otherwise we'd have to use text-builder or text-builder-linear or something of this sort.

Instances

Instances details
MonadFail BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Foldable BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

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

foldMap :: Monoid m => (a -> m) -> BuiltinResult a -> m Source #

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

foldr :: (a -> b -> b) -> b -> BuiltinResult a -> b Source #

foldr' :: (a -> b -> b) -> b -> BuiltinResult a -> b Source #

foldl :: (b -> a -> b) -> b -> BuiltinResult a -> b Source #

foldl' :: (b -> a -> b) -> b -> BuiltinResult a -> b Source #

foldr1 :: (a -> a -> a) -> BuiltinResult a -> a Source #

foldl1 :: (a -> a -> a) -> BuiltinResult a -> a Source #

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

null :: BuiltinResult a -> Bool Source #

length :: BuiltinResult a -> Int Source #

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

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

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

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

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

Applicative BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Functor BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

fmap :: (a -> b) -> BuiltinResult a -> BuiltinResult b Source #

(<$) :: a -> BuiltinResult b -> BuiltinResult a Source #

Monad BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

MonadError BuiltinError BuiltinResult Source #

throwError puts every operational unlifting error into the BuiltinFailure logs. This is to compensate for the historical lack of error message content in operational errors (structural ones don't have this problem) in our evaluators (the CK and CEK machines). It would be better to fix the underlying issue and allow operational evaluation errors to carry some form of content, but for now we just fix the symptom in order for the end user to see the error message that they are supposed to see. The fix even makes some sense: what we do here is we emulate logging when the thrown unlifting error is an operational one, i.e. this is similar to what some builtins do manually (like when a crypto builtin fails and puts info about the failure into the logs).

Instance details

Defined in PlutusCore.Builtin.Result

KnownTypeAst tyname uni a => KnownTypeAst tyname uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (BuiltinResult a) :: Bool Source #

type ToHoles uni (BuiltinResult a) :: [Hole] Source #

type ToBinds uni acc (BuiltinResult a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

MakeKnownIn uni val a => MakeKnownIn uni val (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

(TypeError ('Text "\8216BuiltinResult\8217 cannot appear in the type of an argument") :: Constraint, uni ~ UniOf val) => ReadKnownIn uni val (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Show a => Show (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

_EvaluationFailure :: Prism' (BuiltinResult a) () Source #

AsBuiltinResult (BuiltinResult a) a Source # 
Instance details

Defined in PlutusCore.Builtin.Result

type ToBinds uni acc (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (BuiltinResult a :: Type) = ToBinds uni acc a
type IsBuiltin uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (BuiltinResult a :: Type) = 'False
type ToHoles uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (BuiltinResult a :: Type) = '[TypeHole a :: Hole]

class AsUnliftingEvaluationError r where Source #

Minimal complete definition

_UnliftingEvaluationError

class AsBuiltinResult r a | r -> a where Source #

Minimal complete definition

_BuiltinResult

Methods

_BuiltinResult :: Prism' r (BuiltinResult a) Source #

_BuiltinSuccess :: Prism' r a Source #

_BuiltinSuccessWithLogs :: Prism' r (DList Text, a) Source #

_BuiltinFailure :: Prism' r (DList Text, BuiltinError) Source #

Instances

Instances details
AsBuiltinResult (BuiltinResult a) a Source # 
Instance details

Defined in PlutusCore.Builtin.Result

_UnliftingErrorVia :: Pretty err => err -> Prism' err UnliftingError Source #

Construct a prism focusing on the *EvaluationFailure part of err by taking that *EvaluationFailure and

  1. pretty-printing and embedding it into an UnliftingError for the setter part of the prism
  2. returning it directly for the opposite direction (there's no other way to convert an UnliftingError to an evaluation failure, since the latter doesn't carry any content)

This is useful for providing AsUnliftingError instances for types such as CkUserError and CekUserError.

emit :: Text -> BuiltinResult () Source #

Add a log line to the logs.

withLogs :: DList Text -> BuiltinResult a -> BuiltinResult a Source #

Prepend logs to a BuiltinResult computation.

throwing :: MonadError e m => AReview e t -> t -> m x #

throwing_ :: MonadError e m => AReview e () -> m x #

newtype Opaque val (rep :: Type) Source #

The AST of a value with a Plutus type attached to it. The type is for the Plutus type checker to look at. Opaque can appear in the type of the denotation of a builtin.

Constructors

Opaque 

Fields

Instances

Instances details
KnownTypeAst tyname uni rep => KnownTypeAst tyname uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (Opaque val rep) :: Bool Source #

type ToHoles uni (Opaque val rep) :: [Hole] Source #

type ToBinds uni acc (Opaque val rep) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

uni ~ UniOf val => MakeKnownIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Opaque val rep -> BuiltinResult val Source #

uni ~ UniOf val => ReadKnownIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: val -> ReadKnownM (Opaque val rep) Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Monoid (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

mempty :: Opaque val rep Source #

mappend :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

mconcat :: [Opaque val rep] -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Semigroup (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(<>) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

sconcat :: NonEmpty (Opaque val rep) -> Opaque val rep Source #

stimes :: Integral b => b -> Opaque val rep -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Bounded (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

minBound :: Opaque val rep Source #

maxBound :: Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Enum (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

succ :: Opaque val rep -> Opaque val rep Source #

pred :: Opaque val rep -> Opaque val rep Source #

toEnum :: Int -> Opaque val rep Source #

fromEnum :: Opaque val rep -> Int Source #

enumFrom :: Opaque val rep -> [Opaque val rep] Source #

enumFromThen :: Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

enumFromTo :: Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

enumFromThenTo :: Opaque val rep -> Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Ix (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

range :: (Opaque val rep, Opaque val rep) -> [Opaque val rep] Source #

index :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Int Source #

unsafeIndex :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Int Source #

inRange :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Bool Source #

rangeSize :: (Opaque val rep, Opaque val rep) -> Int Source #

unsafeRangeSize :: (Opaque val rep, Opaque val rep) -> Int Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Num (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(+) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(-) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(*) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

negate :: Opaque val rep -> Opaque val rep Source #

abs :: Opaque val rep -> Opaque val rep Source #

signum :: Opaque val rep -> Opaque val rep Source #

fromInteger :: Integer -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Integral (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

quot :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

rem :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

div :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

mod :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

quotRem :: Opaque val rep -> Opaque val rep -> (Opaque val rep, Opaque val rep) Source #

divMod :: Opaque val rep -> Opaque val rep -> (Opaque val rep, Opaque val rep) Source #

toInteger :: Opaque val rep -> Integer Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Real (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

toRational :: Opaque val rep -> Rational Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Eq (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(==) :: Opaque val rep -> Opaque val rep -> Bool Source #

(/=) :: Opaque val rep -> Opaque val rep -> Bool Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Ord (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

compare :: Opaque val rep -> Opaque val rep -> Ordering Source #

(<) :: Opaque val rep -> Opaque val rep -> Bool Source #

(<=) :: Opaque val rep -> Opaque val rep -> Bool Source #

(>) :: Opaque val rep -> Opaque val rep -> Bool Source #

(>=) :: Opaque val rep -> Opaque val rep -> Bool Source #

max :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

min :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

HasConstant val => HasConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

asConstant :: Opaque val rep -> Either BuiltinError (Some (ValueOf (UniOf (Opaque val rep)))) Source #

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> Opaque val rep Source #

ExMemoryUsage val => ExMemoryUsage (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

memoryUsage :: Opaque val rep -> CostRose Source #

type ToBinds uni acc (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (Opaque val rep :: Type) = ToBinds uni acc rep
type IsBuiltin uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (Opaque val rep :: Type) = 'False
type ToHoles uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (Opaque val rep :: Type) = '[RepHole rep :: Hole]
type UniOf (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

type UniOf (Opaque val rep) = UniOf val

newtype SomeConstant uni (rep :: Type) Source #

For unlifting from the Constant constructor when the stored value is of a monomorphic built-in type

The rep parameter specifies how the type looks on the PLC side (i.e. just like with Opaque val rep).

Constructors

SomeConstant 

Fields

Instances

Instances details
KnownTypeAst tyname uni rep => KnownTypeAst tyname uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (SomeConstant uni rep) :: Bool Source #

type ToHoles uni (SomeConstant uni rep) :: [Hole] Source #

type ToBinds uni acc (SomeConstant uni rep) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

HasConstantIn uni val => MakeKnownIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: SomeConstant uni rep -> BuiltinResult val Source #

HasConstantIn uni val => ReadKnownIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: val -> ReadKnownM (SomeConstant uni rep) Source #

HasConstant (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

(Everywhere uni ExMemoryUsage, Closed uni) => ExMemoryUsage (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

type ToBinds uni acc (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (SomeConstant uni rep :: Type) = ToBinds uni acc rep
type IsBuiltin uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (SomeConstant uni rep :: Type) = 'False
type ToHoles uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (SomeConstant uni rep :: Type) = '[RepHole rep :: Hole]
type UniOf (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

type UniOf (SomeConstant uni rep) = uni

data TyNameRep (kind :: Type) Source #

Representation of a type variable: its name and unique and an implicit kind.

Constructors

TyNameRep Symbol Nat 

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type IsBuiltin uni (MetaForall name a) :: Bool Source #

type ToHoles uni (MetaForall name a) :: [Hole] Source #

type ToBinds uni acc (MetaForall name a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

KnownMonotype val args res => KnownPolytype ('[] :: [Some TyNameRep]) val args res Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

type ToBinds uni acc (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

type ToBinds uni acc (MetaForall name a :: Type) = ToBinds uni (Insert ('Some name) acc) a
type IsBuiltin uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

type IsBuiltin uni (MetaForall name a :: Type) = 'False
type ToHoles uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

type ToHoles uni (MetaForall name a :: Type) = '[TypeHole a :: Hole]

data family TyVarRep (name :: TyNameRep kind) :: kind Source #

Representation of an intrinsically-kinded type variable: a name.

Instances

Instances details
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst tyname uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyVarRep name) :: Bool Source #

type ToHoles uni (TyVarRep name) :: [Hole] Source #

type ToBinds uni acc (TyVarRep name) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

type ToBinds uni acc (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (TyVarRep name :: a) = Insert ('Some name) acc
type IsBuiltin uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (TyVarRep name :: a) = 'False
type ToHoles uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (TyVarRep name :: a) = '[] :: [Hole]

data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #

Representation of an intrinsically-kinded type application: a function and an argument.

Instances

Instances details
(KnownTypeAst tyname uni fun, KnownTypeAst tyname uni arg) => KnownTypeAst tyname uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyAppRep fun arg) :: Bool Source #

type ToHoles uni (TyAppRep fun arg) :: [Hole] Source #

type ToBinds uni acc (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

type ToBinds uni acc (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (TyAppRep fun arg :: a) = ToBinds uni (ToBinds uni acc fun) arg
type IsBuiltin uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (TyAppRep fun arg :: a) = IsBuiltin uni fun && IsBuiltin uni arg
type ToHoles uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (TyAppRep fun arg :: a) = '[RepHole fun :: Hole, RepHole arg :: Hole]

data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #

Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.

Instances

Instances details
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyForallRep name a) :: Bool Source #

type ToHoles uni (TyForallRep name a) :: [Hole] Source #

type ToBinds uni acc (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

type ToBinds uni acc (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (TyForallRep name a :: Type) = Delete ('Some name) (ToBinds uni acc a)
type IsBuiltin uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (TyForallRep name a :: Type) = 'False
type ToHoles uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (TyForallRep name a :: Type) = '[RepHole a :: Hole]

data family BuiltinHead x Source #

For annotating an uninstantiated built-in type, so that it gets handled by the right instance or type family.

Instances

Instances details
Contains uni f => KnownTypeAst tyname uni (BuiltinHead f :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (BuiltinHead f) :: Bool Source #

type ToHoles uni (BuiltinHead f) :: [Hole] Source #

type ToBinds uni acc (BuiltinHead f) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

type ToBinds uni acc (BuiltinHead f :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (BuiltinHead f :: a) = acc
type IsBuiltin uni (BuiltinHead f :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (BuiltinHead f :: a) = 'True
type ToHoles uni (BuiltinHead f :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (BuiltinHead f :: a) = '[] :: [Hole]

type family ElaborateBuiltin uni x Source #

Take an iterated application of a built-in type and elaborate every function application inside of it to TyAppRep and annotate the head with BuiltinHead.

The idea is that we don't need to process built-in types manually if we simply add some annotations for instance resolution to look for. Think what we'd have to do manually for, say, ToHoles: traverse the spine of the application and collect all the holes into a list, which is troubling, because type applications are left-nested and lists are right-nested, so we'd have to use accumulators or an explicit Reverse type family. And then we also have KnownTypeAst and ToBinds, so handling built-in types in a special way for each of those would be a hassle, especially given the fact that type-level Haskell is not exactly good at computing things. With the ElaborateBuiltin approach we get KnownTypeAst, ToHoles and ToBinds for free.

We make this an open type family, so that elaboration is customizable for each universe.

Instances

Instances details
type ElaborateBuiltin DefaultUni (x :: a) Source # 
Instance details

Defined in PlutusCore.Default.Universe

type family AllElaboratedArgs constr x where ... Source #

Take a constraint and use it to constrain every argument of a possibly 0-ary elaborated application of a built-in type.

Equations

AllElaboratedArgs constr (f `TyAppRep` x) = (constr x, AllElaboratedArgs constr f) 
AllElaboratedArgs _ (BuiltinHead _) = () 

class AllElaboratedArgs constr (ElaborateBuiltin uni x) => AllBuiltinArgs uni constr x Source #

Take a constraint and use it to constrain every argument of a possibly 0-ary application of a built-in type.

Instances

Instances details
AllElaboratedArgs constr (ElaborateBuiltin uni x) => AllBuiltinArgs uni constr (x :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

type family FoldArgs args res where ... Source #

Turn a list of Haskell types args into a functional type ending in res.

>>> :set -XDataKinds
>>> :kind! FoldArgs [(), Bool] Integer
FoldArgs [(), Bool] Integer :: *
= () -> Bool -> Integer

Equations

FoldArgs '[] res = res 
FoldArgs (arg ': args) res = arg -> FoldArgs args res 

data BuiltinMeaning val cost Source #

The meaning of a built-in function consists of its type represented as a TypeScheme, its Haskell denotation and its uninstantiated runtime denotation.

The TypeScheme of a built-in function is used for example for

  1. computing the PLC type of the function to be used during type checking
  2. getting arity information
  3. generating arbitrary values to apply the function to in tests

The denotation is lazy, so that we don't need to worry about a builtin being bottom (happens in tests). The production path is not affected by that, since only runtime denotations are used for evaluation.

Constructors

forall args res. BuiltinMeaning (TypeScheme val args res) ~(FoldArgs args res) (cost -> BuiltinRuntime val) 

type HasMeaningIn uni val = (Typeable val, ExMemoryUsage val, HasConstantIn uni val) Source #

Constraints available when defining a built-in function.

class (Typeable uni, Typeable fun, Bounded fun, Enum fun, Ix fun, Default (BuiltinSemanticsVariant fun)) => ToBuiltinMeaning uni fun where Source #

A type class for "each function from a set of built-in functions has a BuiltinMeaning".

Associated Types

type CostingPart uni fun Source #

The cost part of BuiltinMeaning.

data BuiltinSemanticsVariant fun Source #

See Note [Builtin semantics variants]

Methods

toBuiltinMeaning :: HasMeaningIn uni val => BuiltinSemanticsVariant fun -> fun -> BuiltinMeaning val (CostingPart uni fun) Source #

Get the BuiltinMeaning of a built-in function.

withTypeSchemeOfBuiltinFunction :: forall val fun r. (ToBuiltinMeaning (UniOf val) fun, ExMemoryUsage val, Typeable val, HasConstant val) => BuiltinSemanticsVariant fun -> fun -> (forall args res. TypeScheme val args res -> r) -> r Source #

Feed the TypeScheme of the given built-in function to the continuation.

typeOfBuiltinFunction :: forall uni fun. ToBuiltinMeaning uni fun => BuiltinSemanticsVariant fun -> fun -> Type TyName uni () Source #

Get the type of a built-in function.

type family GetArgs a where ... Source #

Chop a function type to get a list of its argument types.

Equations

GetArgs (a -> b) = a ': GetArgs b 
GetArgs _ = '[] 

class KnownMonotype val args res where Source #

A class that allows us to derive a monotype for a builtin. We could've computed the runtime denotation from the TypeScheme and the denotation of the builtin, but not statically (due to unfolding not working for recursive functions and TypeScheme being recursive, i.e. requiring the conversion function to be recursive), and so it would cause us to retain a lot of evaluation-irrelevant stuff in the constructors of BuiltinRuntime, which has to make evaluation slower (we didn't check) and certainly makes the generated Core much harder to read. Technically speaking, we could get a RuntimeScheme from the TypeScheme and the denotation statically if we changed the definition of TypeScheme and made it a singleton, but then the conversion function would have to become a class anyway and we'd just replicate what we have here, except in a much more complicated way.

Methods

knownMonotype :: TypeScheme val args res Source #

toMonoF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val Source #

Convert the denotation of a builtin to its runtime counterpart . The argument is in ReadKnownM, because that's what deferred unlifting amounts to: passing the action returning the builtin application around until full saturation, which is when the action actually gets run.

Instances

Instances details
(Typeable res, KnownTypeAst TyName (UniOf val) res, MakeKnown val res) => KnownMonotype val ('[] :: [Type]) res Source #

Once we've run out of term-level arguments, we return a TypeSchemeResult/RuntimeSchemeResult.

Instance details

Defined in PlutusCore.Builtin.Meaning

(Typeable arg, KnownTypeAst TyName (UniOf val) arg, MakeKnown val arg, ReadKnown val arg, KnownMonotype val args res) => KnownMonotype val (arg ': args) res Source #

Every term-level argument becomes a TypeSchemeArrow/RuntimeSchemeArrow.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownMonotype :: TypeScheme val (arg ': args) res Source #

toMonoF :: ReadKnownM (FoldArgs (arg ': args) res, FoldArgs (arg ': args) ExBudgetStream) -> BuiltinRuntime val Source #

class KnownMonotype val args res => KnownPolytype (binds :: [Some TyNameRep]) val args res where Source #

A class that allows us to derive a polytype for a builtin.

Methods

knownPolytype :: TypeScheme val args res Source #

toPolyF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val Source #

Convert the denotation of a builtin to its runtime counterpart. The argument is in ReadKnownM, because that's what we need to do: passing the action returning the builtin application around until full saturation, which is when the action actually gets run.

Instances

Instances details
KnownMonotype val args res => KnownPolytype ('[] :: [Some TyNameRep]) val args res Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

type family ThrowOnBothEmpty binds args isBuiltin a where ... Source #

Ensure a built-in function is not nullary and throw a nice error otherwise.

Equations

ThrowOnBothEmpty '[] '[] 'True a = TypeError (('Text "A built-in function must take at least one type or term argument" ':$$: ((('Text "\8216" ':<>: 'ShowType a) ':<>: 'Text "\8217 is a built-in type") ':<>: 'Text " so you can embed any of its values as a constant")) ':$$: 'Text "If you still want a built-in function, add a dummy \8216()\8217 argument") 
ThrowOnBothEmpty '[] '[] 'False a = TypeError ('Text "A built-in function must take at least one type or term argument" ':$$: 'Text "To fix this error add a dummy \8216()\8217 argument") 
ThrowOnBothEmpty _ _ _ _ = () 

class MakeBuiltinMeaning a val where Source #

A function turned into a type class with exactly one fully general instance. We can't package up the constraints of makeBuiltinMeaning (see the instance) into a type or class synonym, because they contain a bunch of variables defined by ~ or determined via functional dependencies and neither class nor type definitions can handle that (see https://gitlab.haskell.org/ghc/ghc/-/issues/7100). Inlining three lines of constraints whenever we need to call makeBuiltinMeaning over a non-concrete type is a bad option and this abstraction is free anyway, hence its existence.

The a type variable goes first, because makeBuiltinMeaning @A is a common pattern.

Methods

makeBuiltinMeaning :: a -> (cost -> FoldArgs (GetArgs a) ExBudgetStream) -> BuiltinMeaning val cost Source #

Construct the meaning for a built-in function by automatically deriving its TypeScheme, given

  1. the denotation of the builtin
  2. an uninstantiated costing function

Instances

Instances details
(uni ~ UniOf val, binds ~ ToBinds uni ('[] :: [Some TyNameRep]) a, args ~ GetArgs a, a ~ FoldArgs args res, ThrowOnBothEmpty binds args (IsBuiltin uni a) a, ElaborateFromTo uni 0 j val a, KnownPolytype binds val args res) => MakeBuiltinMeaning a val Source # 
Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

makeBuiltinMeaning :: a -> (cost -> FoldArgs (GetArgs a) ExBudgetStream) -> BuiltinMeaning val cost Source #

toBuiltinRuntime :: cost -> BuiltinMeaning val cost -> BuiltinRuntime val Source #

Convert a BuiltinMeaning to a BuiltinRuntime given a cost model.

toBuiltinsRuntime :: (cost ~ CostingPart uni fun, ToBuiltinMeaning uni fun, HasMeaningIn uni val) => BuiltinSemanticsVariant fun -> cost -> BuiltinsRuntime fun val Source #

Calculate runtime info for all built-in functions given meanings of builtins (as a constraint), the semantics variant of the set of builtins and a cost model.

data TyNameRep (kind :: Type) Source #

Representation of a type variable: its name and unique and an implicit kind.

Constructors

TyNameRep Symbol Nat 

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type IsBuiltin uni (MetaForall name a) :: Bool Source #

type ToHoles uni (MetaForall name a) :: [Hole] Source #

type ToBinds uni acc (MetaForall name a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

KnownMonotype val args res => KnownPolytype ('[] :: [Some TyNameRep]) val args res Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

type ToBinds uni acc (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

type ToBinds uni acc (MetaForall name a :: Type) = ToBinds uni (Insert ('Some name) acc) a
type IsBuiltin uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

type IsBuiltin uni (MetaForall name a :: Type) = 'False
type ToHoles uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

type ToHoles uni (MetaForall name a :: Type) = '[TypeHole a :: Hole]

data family TyVarRep (name :: TyNameRep kind) :: kind Source #

Representation of an intrinsically-kinded type variable: a name.

Instances

Instances details
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst tyname uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyVarRep name) :: Bool Source #

type ToHoles uni (TyVarRep name) :: [Hole] Source #

type ToBinds uni acc (TyVarRep name) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

type ToBinds uni acc (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (TyVarRep name :: a) = Insert ('Some name) acc
type IsBuiltin uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (TyVarRep name :: a) = 'False
type ToHoles uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (TyVarRep name :: a) = '[] :: [Hole]

data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #

Representation of an intrinsically-kinded type application: a function and an argument.

Instances

Instances details
(KnownTypeAst tyname uni fun, KnownTypeAst tyname uni arg) => KnownTypeAst tyname uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyAppRep fun arg) :: Bool Source #

type ToHoles uni (TyAppRep fun arg) :: [Hole] Source #

type ToBinds uni acc (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

type ToBinds uni acc (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (TyAppRep fun arg :: a) = ToBinds uni (ToBinds uni acc fun) arg
type IsBuiltin uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (TyAppRep fun arg :: a) = IsBuiltin uni fun && IsBuiltin uni arg
type ToHoles uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (TyAppRep fun arg :: a) = '[RepHole fun :: Hole, RepHole arg :: Hole]

data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #

Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.

Instances

Instances details
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyForallRep name a) :: Bool Source #

type ToHoles uni (TyForallRep name a) :: [Hole] Source #

type ToBinds uni acc (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

type ToBinds uni acc (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (TyForallRep name a :: Type) = Delete ('Some name) (ToBinds uni acc a)
type IsBuiltin uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (TyForallRep name a :: Type) = 'False
type ToHoles uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (TyForallRep name a :: Type) = '[RepHole a :: Hole]

data Hole Source #

The kind of holes.

data family RepHole x Source #

A hole in the Rep context.

type HasTermLevel uni = Includes uni Source #

Specifies that the given type is a built-in one and its values can be embedded into a Term.

type HasTypeLevel uni x = KnownTypeAst Void uni (ElaborateBuiltin uni x) Source #

Specifies that the given type is a built-in one and can be embedded into a Kind.

type HasTypeAndTermLevel uni x = (uni `HasTypeLevel` x, uni `HasTermLevel` x) Source #

The product of HasTypeLevel and HasTermLevel.

mkTyBuiltin :: forall a (x :: a) uni ann tyname. uni `HasTypeLevel` x => ann -> Type tyname uni ann Source #

Convert a Haskell representation of a possibly 0-ary application of a built-in type to arbitrary types implementing KnownTypeAst.

data family TypeHole a Source #

A hole in the Type context.

type KnownBuiltinTypeAst tyname uni x = AllBuiltinArgs uni (KnownTypeAst tyname uni) x Source #

A constraint for "a is a KnownTypeAst by means of being included in uni".

class KnownTypeAst tyname uni x where Source #

This class allows one to convert the type-level Haskell representation of a Plutus type into the corresponding Plutus type. Associated type families are needed to help elaboration.

Depending on the universe converting a Haskell type to a Plutus team can give different results (e.g. Int can be a built-in type instead of being encoded via built-in Integer), hence this class takes a uni argument. Plus, elaboration is universe-specific too.

Minimal complete definition

Nothing

Associated Types

type IsBuiltin uni x :: Bool Source #

Whether x is a built-in type.

type IsBuiltin uni x = IsBuiltin uni (ElaborateBuiltin uni x)

type ToHoles uni x :: [Hole] Source #

Return every part of the type that can be a to-be-instantiated type variable. For example, in Integer there's no such types and in (a, b) it's the two arguments (a and b) and the same applies to a -> b (to mention a type that is not built-in).

type ToHoles uni x = ToHoles uni (ElaborateBuiltin uni x)

type ToBinds uni (acc :: [Some TyNameRep]) x :: [Some TyNameRep] Source #

Collect all unique variables (a variable consists of a textual name, a unique and a kind) in an accumulator and return the accumulator once a leaf is reached.

type ToBinds uni acc x = ToBinds uni acc (ElaborateBuiltin uni x)

Methods

typeAst :: Type tyname uni () Source #

The Plutus counterpart of the x type.

default typeAst :: KnownTypeAst tyname uni (ElaborateBuiltin uni x) => Type tyname uni () Source #

Instances

Instances details
tyname ~ TyName => KnownTypeAst tyname DefaultUni Void Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Int16 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Int32 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Int64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Int8 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Word16 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Word32 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Word64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Word8 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni ByteString => KnownTypeAst tyname DefaultUni ByteString Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni Element => KnownTypeAst tyname DefaultUni Element Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni Element => KnownTypeAst tyname DefaultUni Element Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni MlResult => KnownTypeAst tyname DefaultUni MlResult Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni Data => KnownTypeAst tyname DefaultUni Data Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni IntegerCostedLiterally Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni NumBytesCostedAsNumWords Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni Text => KnownTypeAst tyname DefaultUni Text Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni Integer => KnownTypeAst tyname DefaultUni Integer Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Natural Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni () => KnownTypeAst tyname DefaultUni () Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type IsBuiltin DefaultUni () :: Bool Source #

type ToHoles DefaultUni () :: [Hole] Source #

type ToBinds DefaultUni acc () :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni Bool => KnownTypeAst tyname DefaultUni Bool Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Int Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type IsBuiltin DefaultUni Int :: Bool Source #

type ToHoles DefaultUni Int :: [Hole] Source #

type ToBinds DefaultUni acc Int :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni Word Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type tyname DefaultUni () Source #

KnownTypeAst tyname DefaultUni a => KnownTypeAst tyname DefaultUni (ListCostedByLength a :: Type) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

typeAst :: Type0 tyname DefaultUni () Source #

KnownBuiltinTypeAst tyname DefaultUni [a] => KnownTypeAst tyname DefaultUni ([a] :: Type) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type IsBuiltin DefaultUni [a] :: Bool Source #

type ToHoles DefaultUni [a] :: [Hole] Source #

type ToBinds DefaultUni acc [a] :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname DefaultUni () Source #

KnownTypeAst tyname uni a => KnownTypeAst tyname uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (BuiltinResult a) :: Bool Source #

type ToHoles uni (BuiltinResult a) :: [Hole] Source #

type ToBinds uni acc (BuiltinResult a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

KnownTypeAst tyname uni a => KnownTypeAst tyname uni (EvaluationResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (EvaluationResult a) :: Bool Source #

type ToHoles uni (EvaluationResult a) :: [Hole] Source #

type ToBinds uni acc (EvaluationResult a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

(tyname ~ TyName, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (PlcListRep a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type IsBuiltin uni (PlcListRep a) :: Bool Source #

type ToHoles uni (PlcListRep a) :: [Hole] Source #

type ToBinds uni acc (PlcListRep a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

KnownBuiltinTypeAst tyname DefaultUni (a, b) => KnownTypeAst tyname DefaultUni ((a, b) :: Type) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type IsBuiltin DefaultUni (a, b) :: Bool Source #

type ToHoles DefaultUni (a, b) :: [Hole] Source #

type ToBinds DefaultUni acc (a, b) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname DefaultUni () Source #

KnownTypeAst tyname uni rep => KnownTypeAst tyname uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (Opaque val rep) :: Bool Source #

type ToHoles uni (Opaque val rep) :: [Hole] Source #

type ToBinds uni acc (Opaque val rep) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

KnownTypeAst tyname uni rep => KnownTypeAst tyname uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (SomeConstant uni rep) :: Bool Source #

type ToHoles uni (SomeConstant uni rep) :: [Hole] Source #

type ToBinds uni acc (SomeConstant uni rep) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

(KnownTypeAst tyname uni a, KnownTypeAst tyname uni b) => KnownTypeAst tyname uni (a -> b :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (a -> b) :: Bool Source #

type ToHoles uni (a -> b) :: [Hole] Source #

type ToBinds uni acc (a -> b) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

Contains uni f => KnownTypeAst tyname uni (BuiltinHead f :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (BuiltinHead f) :: Bool Source #

type ToHoles uni (BuiltinHead f) :: [Hole] Source #

type ToBinds uni acc (BuiltinHead f) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst tyname uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyVarRep name) :: Bool Source #

type ToHoles uni (TyVarRep name) :: [Hole] Source #

type ToBinds uni acc (TyVarRep name) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyForallRep name a) :: Bool Source #

type ToHoles uni (TyForallRep name a) :: [Hole] Source #

type ToBinds uni acc (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (MetaForall name a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type IsBuiltin uni (MetaForall name a) :: Bool Source #

type ToHoles uni (MetaForall name a) :: [Hole] Source #

type ToBinds uni acc (MetaForall name a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

(KnownTypeAst tyname uni fun, KnownTypeAst tyname uni arg) => KnownTypeAst tyname uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (TyAppRep fun arg) :: Bool Source #

type ToHoles uni (TyAppRep fun arg) :: [Hole] Source #

type ToBinds uni acc (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

typeAst :: Type tyname uni () Source #

toTypeAst :: forall a tyname uni (x :: a) proxy. KnownTypeAst tyname uni x => proxy x -> Type tyname uni () Source #

Return the Plutus counterpart of the x type.

type family Insert x xs where ... Source #

Insert x into xs unless it's already there.

Equations

Insert x '[] = '[x] 
Insert x (x : xs) = x ': xs 
Insert x (y : xs) = y ': Insert x xs 

type family Delete x xs where ... Source #

Delete the first x from a list. Which is okay since we only ever put things in once.

Equations

Delete _ '[] = '[] 
Delete x (x ': xs) = xs 
Delete x (y ': xs) = y ': Delete x xs 

data BuiltinError Source #

The type of errors that readKnown and makeKnown can return.

Instances

Instances details
Show BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Eq BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsBuiltinError BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsUnliftingEvaluationError BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Pretty BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

pretty :: BuiltinError -> Doc ann #

prettyList :: [BuiltinError] -> Doc ann #

MonadError BuiltinError BuiltinResult Source #

throwError puts every operational unlifting error into the BuiltinFailure logs. This is to compensate for the historical lack of error message content in operational errors (structural ones don't have this problem) in our evaluators (the CK and CEK machines). It would be better to fix the underlying issue and allow operational evaluation errors to carry some form of content, but for now we just fix the symptom in order for the end user to see the error message that they are supposed to see. The fix even makes some sense: what we do here is we emulate logging when the thrown unlifting error is an operational one, i.e. this is similar to what some builtins do manually (like when a crypto builtin fails and puts info about the failure into the logs).

Instance details

Defined in PlutusCore.Builtin.Result

throwBuiltinErrorWithCause :: (MonadError (ErrorWithCause err cause) m, AsUnliftingEvaluationError err, AsEvaluationFailure err) => cause -> BuiltinError -> m void Source #

Attach a cause to a BuiltinError and throw that. Note that an evaluator might require the cause to be computed lazily for best performance on the happy path, hence this function must not force its first argument. TODO: wrap cause in Lazy once we have it.

type KnownBuiltinTypeIn uni val a = (HasConstantIn uni val, PrettyParens (SomeTypeIn uni), GEq uni, uni `HasTermLevel` a) Source #

A constraint for "a is a ReadKnownIn and MakeKnownIn by means of being included in uni".

type KnownBuiltinType val a = KnownBuiltinTypeIn (UniOf val) val a Source #

A constraint for "a is a ReadKnownIn and MakeKnownIn by means of being included in UniOf term".

data BuiltinResult a Source #

The monad that makeKnown runs in. Equivalent to ExceptT BuiltinError (Writer (DList Text)), except optimized in two ways:

  1. everything is strict
  2. has the BuiltinSuccess constructor that is used for returning a value with no logs attached, which is the most common case for us, so it helps a lot not to construct and deconstruct a redundant tuple

Moving from ExceptT BuiltinError (Writer (DList Text)) to this data type gave us a speedup of 8% of total evaluation time.

Logs are represented as a DList, because we don't particularly care about the efficiency of logging, since there's no logging on the chain and builtins don't emit much anyway. Otherwise we'd have to use text-builder or text-builder-linear or something of this sort.

Instances

Instances details
MonadFail BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Foldable BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

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

foldMap :: Monoid m => (a -> m) -> BuiltinResult a -> m Source #

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

foldr :: (a -> b -> b) -> b -> BuiltinResult a -> b Source #

foldr' :: (a -> b -> b) -> b -> BuiltinResult a -> b Source #

foldl :: (b -> a -> b) -> b -> BuiltinResult a -> b Source #

foldl' :: (b -> a -> b) -> b -> BuiltinResult a -> b Source #

foldr1 :: (a -> a -> a) -> BuiltinResult a -> a Source #

foldl1 :: (a -> a -> a) -> BuiltinResult a -> a Source #

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

null :: BuiltinResult a -> Bool Source #

length :: BuiltinResult a -> Int Source #

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

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

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

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

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

Applicative BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Functor BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

fmap :: (a -> b) -> BuiltinResult a -> BuiltinResult b Source #

(<$) :: a -> BuiltinResult b -> BuiltinResult a Source #

Monad BuiltinResult Source # 
Instance details

Defined in PlutusCore.Builtin.Result

MonadError BuiltinError BuiltinResult Source #

throwError puts every operational unlifting error into the BuiltinFailure logs. This is to compensate for the historical lack of error message content in operational errors (structural ones don't have this problem) in our evaluators (the CK and CEK machines). It would be better to fix the underlying issue and allow operational evaluation errors to carry some form of content, but for now we just fix the symptom in order for the end user to see the error message that they are supposed to see. The fix even makes some sense: what we do here is we emulate logging when the thrown unlifting error is an operational one, i.e. this is similar to what some builtins do manually (like when a crypto builtin fails and puts info about the failure into the logs).

Instance details

Defined in PlutusCore.Builtin.Result

KnownTypeAst tyname uni a => KnownTypeAst tyname uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type IsBuiltin uni (BuiltinResult a) :: Bool Source #

type ToHoles uni (BuiltinResult a) :: [Hole] Source #

type ToBinds uni acc (BuiltinResult a) :: [Some TyNameRep] Source #

Methods

typeAst :: Type0 tyname uni () Source #

MakeKnownIn uni val a => MakeKnownIn uni val (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

(TypeError ('Text "\8216BuiltinResult\8217 cannot appear in the type of an argument") :: Constraint, uni ~ UniOf val) => ReadKnownIn uni val (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Show a => Show (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

_EvaluationFailure :: Prism' (BuiltinResult a) () Source #

AsBuiltinResult (BuiltinResult a) a Source # 
Instance details

Defined in PlutusCore.Builtin.Result

type ToBinds uni acc (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (BuiltinResult a :: Type) = ToBinds uni acc a
type IsBuiltin uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type IsBuiltin uni (BuiltinResult a :: Type) = 'False
type ToHoles uni (BuiltinResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni (BuiltinResult a :: Type) = '[TypeHole a :: Hole]

type ReadKnownM = Either BuiltinError Source #

The monad that readKnown runs in.

class uni ~ UniOf val => MakeKnownIn uni val a where Source #

Minimal complete definition

Nothing

Methods

makeKnown :: a -> BuiltinResult val Source #

Convert a Haskell value to the corresponding PLC value. The inverse of readKnown.

default makeKnown :: KnownBuiltinType val a => a -> BuiltinResult val Source #

Instances

Instances details
UniOf term ~ DefaultUni => MakeKnownIn DefaultUni term Void Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Methods

makeKnown :: Void -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Int16 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Int32 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Int64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Int8 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Int8 -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Word16 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Word32 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Word64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Word8 Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term ByteString => MakeKnownIn DefaultUni term ByteString Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Element => MakeKnownIn DefaultUni term Element Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Element => MakeKnownIn DefaultUni term Element Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term MlResult => MakeKnownIn DefaultUni term MlResult Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Data => MakeKnownIn DefaultUni term Data Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Data -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term IntegerCostedLiterally Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term NumBytesCostedAsNumWords Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Text => MakeKnownIn DefaultUni term Text Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Text -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Integer Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Natural Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term () => MakeKnownIn DefaultUni term () Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: () -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Bool => MakeKnownIn DefaultUni term Bool Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Bool -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Int Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Int -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term Integer => MakeKnownIn DefaultUni term Word Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Word -> BuiltinResult term Source #

KnownBuiltinTypeIn DefaultUni term [a] => MakeKnownIn DefaultUni term (ListCostedByLength a) Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term [a] => MakeKnownIn DefaultUni term [a] Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: [a] -> BuiltinResult term Source #

MakeKnownIn uni val a => MakeKnownIn uni val (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

(TypeError ('Text "Use \8216BuiltinResult\8217 instead of \8216EvaluationResult\8217") :: Constraint, uni ~ UniOf val) => MakeKnownIn uni val (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

KnownBuiltinTypeIn DefaultUni term (a, b) => MakeKnownIn DefaultUni term (a, b) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (a, b) -> BuiltinResult term Source #

uni ~ UniOf val => MakeKnownIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Opaque val rep -> BuiltinResult val Source #

HasConstantIn uni val => MakeKnownIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: SomeConstant uni rep -> BuiltinResult val Source #

MakeKnownIn DefaultUni term a => MakeKnownIn DefaultUni term (MetaForall name a) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Methods

makeKnown :: MetaForall name a -> BuiltinResult term Source #

readKnownConstant :: forall val a. KnownBuiltinType val a => val -> ReadKnownM a Source #

Convert a constant embedded into a PLC term to the corresponding Haskell value.

type MakeKnown val = MakeKnownIn (UniOf val) val Source #

class uni ~ UniOf val => ReadKnownIn uni val a where Source #

Minimal complete definition

Nothing

Methods

readKnown :: val -> ReadKnownM a Source #

Convert a PLC value to the corresponding Haskell value. The inverse of makeKnown.

default readKnown :: KnownBuiltinType val a => val -> ReadKnownM a Source #

Instances

Instances details
UniOf term ~ DefaultUni => ReadKnownIn DefaultUni term Void Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Methods

readKnown :: term -> ReadKnownM Void Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Int16 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Int16 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Int32 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Int32 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Int64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Int64 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Int8 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Int8 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Word16 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Word16 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Word32 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Word32 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Word64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Word64 Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Word8 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Word8 Source #

KnownBuiltinTypeIn DefaultUni term ByteString => ReadKnownIn DefaultUni term ByteString Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Element => ReadKnownIn DefaultUni term Element Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Element Source #

KnownBuiltinTypeIn DefaultUni term Element => ReadKnownIn DefaultUni term Element Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Element Source #

KnownBuiltinTypeIn DefaultUni term MlResult => ReadKnownIn DefaultUni term MlResult Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Data => ReadKnownIn DefaultUni term Data Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Data Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term IntegerCostedLiterally Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term NumBytesCostedAsNumWords Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term Text => ReadKnownIn DefaultUni term Text Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Text Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Integer Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Integer Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Natural Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Natural Source #

KnownBuiltinTypeIn DefaultUni term () => ReadKnownIn DefaultUni term () Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM () Source #

KnownBuiltinTypeIn DefaultUni term Bool => ReadKnownIn DefaultUni term Bool Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Bool Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Int Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Int Source #

KnownBuiltinTypeIn DefaultUni term Integer => ReadKnownIn DefaultUni term Word Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM Word Source #

KnownBuiltinTypeIn DefaultUni term [a] => ReadKnownIn DefaultUni term (ListCostedByLength a) Source # 
Instance details

Defined in PlutusCore.Default.Universe

KnownBuiltinTypeIn DefaultUni term [a] => ReadKnownIn DefaultUni term [a] Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM [a] Source #

(TypeError ('Text "\8216BuiltinResult\8217 cannot appear in the type of an argument") :: Constraint, uni ~ UniOf val) => ReadKnownIn uni val (BuiltinResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

(TypeError ('Text "Use \8216BuiltinResult\8217 instead of \8216EvaluationResult\8217") :: Constraint, uni ~ UniOf val) => ReadKnownIn uni val (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

KnownBuiltinTypeIn DefaultUni term (a, b) => ReadKnownIn DefaultUni term (a, b) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: term -> ReadKnownM (a, b) Source #

uni ~ UniOf val => ReadKnownIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: val -> ReadKnownM (Opaque val rep) Source #

HasConstantIn uni val => ReadKnownIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: val -> ReadKnownM (SomeConstant uni rep) Source #

type ReadKnown val = ReadKnownIn (UniOf val) val Source #

makeKnownOrFail :: MakeKnownIn uni val a => a -> EvaluationResult val Source #

Same as makeKnown, but allows for neither emitting nor storing the cause of a failure.

readKnownSelf :: (ReadKnown val a, AsUnliftingEvaluationError err, AsEvaluationFailure err) => val -> Either (ErrorWithCause err val) a Source #

Same as readKnown, but the cause of a potential failure is the provided term itself.

data SingKind k where Source #

The type of singletonized Haskell kinds representing Plutus kinds. Indexing by a Haskell kind allows us to avoid an error call in the ToKind instance of DefaultUni and not worry about proxies in the type of knownKind.

Constructors

SingType :: SingKind Type 
SingKindArrow :: SingKind k -> SingKind l -> SingKind (k -> l) infixr 5 

withSingKind :: Kind ann -> (forall k. SingKind k -> r) -> r Source #

Feed the SingKind version of the given Kind to the given continuation.

class KnownKind k where Source #

For reifying Haskell kinds representing Plutus kinds at the term level.

Instances

Instances details
rep ~ LiftedRep => KnownKind (TYPE rep) Source #

Plutus only supports lifted types, hence the equality constraint.

Instance details

Defined in PlutusCore.Builtin.KnownKind

Methods

knownKind :: SingKind (TYPE rep) Source #

(KnownKind dom, KnownKind cod) => KnownKind (dom -> cod) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownKind

Methods

knownKind :: SingKind (dom -> cod) Source #

bringKnownKind :: SingKind k -> (KnownKind k => r) -> r Source #

Satisfy the KnownKind constraint of a continuation using the given SingKind.

withKnownKind :: Kind ann -> (forall k. KnownKind k => Proxy k -> r) -> r Source #

class ToKind (uni :: Type -> Type) where Source #

For computing the Plutus kind of a built-in type. See kindOfBuiltinType.

Methods

toSingKind :: uni (Esc (a :: k)) -> SingKind k Source #

Reify the kind of a type from the universe at the term level.

Instances

Instances details
ToKind DefaultUni Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

toSingKind :: forall k (a :: k). DefaultUni (Esc a) -> SingKind k Source #

demoteKind :: SingKind k -> Kind () Source #

Convert a reified Haskell kind to a Plutus kind.

kindOfBuiltinType :: ToKind uni => uni (Esc a) -> Kind () Source #

Compute the kind of a type from a universe.

data BuiltinError Source #

The type of errors that readKnown and makeKnown can return.

Instances

Instances details
Show BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Eq BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsBuiltinError BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsUnliftingEvaluationError BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Pretty BuiltinError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

Methods

pretty :: BuiltinError -> Doc ann #

prettyList :: [BuiltinError] -> Doc ann #

MonadError BuiltinError BuiltinResult Source #

throwError puts every operational unlifting error into the BuiltinFailure logs. This is to compensate for the historical lack of error message content in operational errors (structural ones don't have this problem) in our evaluators (the CK and CEK machines). It would be better to fix the underlying issue and allow operational evaluation errors to carry some form of content, but for now we just fix the symptom in order for the end user to see the error message that they are supposed to see. The fix even makes some sense: what we do here is we emulate logging when the thrown unlifting error is an operational one, i.e. this is similar to what some builtins do manually (like when a crypto builtin fails and puts info about the failure into the logs).

Instance details

Defined in PlutusCore.Builtin.Result

class HasConstant term where Source #

Ensures that term has a Constant-like constructor to lift values to and unlift values from.

Methods

asConstant :: term -> Either BuiltinError (Some (ValueOf (UniOf term))) Source #

Unwrap from a Constant-like constructor throwing an UnliftingError if the provided term is not a wrapped Haskell value.

fromConstant :: Some (ValueOf (UniOf term)) -> term Source #

Wrap a Haskell value as a term.

Instances

Instances details
HasConstant val => HasConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

asConstant :: Opaque val rep -> Either BuiltinError (Some (ValueOf (UniOf (Opaque val rep)))) Source #

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> Opaque val rep Source #

HasConstant (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

HasConstant (CkValue uni fun) Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

Methods

asConstant :: CkValue uni fun -> Either BuiltinError (Some (ValueOf (UniOf (CkValue uni fun)))) Source #

fromConstant :: Some (ValueOf (UniOf (CkValue uni fun))) -> CkValue uni fun Source #

HasConstant (CekValue uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

asConstant :: CekValue uni fun ann -> Either BuiltinError (Some (ValueOf (UniOf (CekValue uni fun ann)))) Source #

fromConstant :: Some (ValueOf (UniOf (CekValue uni fun ann))) -> CekValue uni fun ann Source #

HasConstant (Term name uni fun ()) Source # 
Instance details

Defined in UntypedPlutusCore.Core.Type

Methods

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

fromConstant :: Some (ValueOf (UniOf (Term name uni fun ()))) -> Term name uni fun () 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 HasConstantIn uni term = (UniOf term ~ uni, HasConstant term) Source #

Ensures that term has a Constant-like constructor to lift values to and unlift values from and connects term and its uni.

fromValueOf :: forall a term. HasConstant term => UniOf term (Esc a) -> a -> term Source #

Wrap a Haskell value (given its explicit type tag) as a term.

fromValue :: forall a term. (HasConstant term, UniOf term `HasTermLevel` a) => a -> term Source #

Wrap a Haskell value (provided its type is in the universe) as a term.