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

PlutusCore.Builtin.Runtime

Synopsis

Documentation

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

Methods

showsPrecIntBuiltinRuntime (CkValue uni fun) → ShowS Source #

showBuiltinRuntime (CkValue uni fun) → String Source #

showList ∷ [BuiltinRuntime (CkValue uni fun)] → ShowS Source #

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

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

showsPrecIntBuiltinRuntime (CekValue uni fun ann) → ShowS Source #

showBuiltinRuntime (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

rnfBuiltinRuntime val → () Source #

NoThunks (BuiltinRuntime val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

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

rnfBuiltinsRuntime fun val → () Source #

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

Defined in PlutusCore.Builtin.Runtime

lookupBuiltin ∷ fun → BuiltinsRuntime fun val → BuiltinRuntime val Source #

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