plutus-core
Safe HaskellNone
LanguageHaskell2010

UntypedPlutusCore.Evaluation.Machine.SteppableCek.Internal

Description

The CEK machine. The CEK machine relies on variables having non-equal Uniques whenever they have non-equal string names. I.e. Uniques are used instead of string names. This is for efficiency reasons. The CEK machines handles name capture by design.

Synopsis

Documentation

data CekState (uni :: Type -> Type) fun ann Source #

Constructors

Starting (NTerm uni fun ann) 
Computing (Context uni fun ann) (CekValEnv uni fun ann) (NTerm uni fun ann) 
Returning (Context uni fun ann) (CekValue uni fun ann) 
Terminating (DischargeResult uni fun) 

Instances

Instances details
Pretty (CekState uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.SteppableCek.Internal

Methods

pretty :: CekState uni fun ann -> Doc ann0 #

prettyList :: [CekState uni fun ann] -> Doc ann0 #

data Context (uni :: Type -> Type) fun ann Source #

Similar to Context, but augmented with an ann

Constructors

FrameAwaitArg ann !(CekValue uni fun ann) !(Context uni fun ann)
[V _]
FrameAwaitFunTerm ann !(CekValEnv uni fun ann) !(NTerm uni fun ann) !(Context uni fun ann)
[_ N]
FrameAwaitFunConN ann !(Spine (Some (ValueOf uni))) !(Context uni fun ann) 
FrameAwaitFunValueN ann !(ArgStackNonEmpty uni fun ann) !(Context uni fun ann) 
FrameForce ann !(Context uni fun ann)
(force _)
FrameConstr ann !(CekValEnv uni fun ann) !Word64 ![NTerm uni fun ann] !(ArgStack uni fun ann) !(Context uni fun ann) 
FrameCases ann !(CekValEnv uni fun ann) !(Vector (NTerm uni fun ann)) !(Context uni fun ann) 
NoFrame 

Instances

Instances details
(GShow uni, Everywhere uni Show, Show fun, Show ann, Closed uni) => Show (Context uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.SteppableCek.Internal

Methods

showsPrec :: Int -> Context uni fun ann -> ShowS Source #

show :: Context uni fun ann -> String Source #

showList :: [Context uni fun ann] -> ShowS Source #

contextAnn :: forall (uni :: Type -> Type) fun ann. Context uni fun ann -> Maybe ann Source #

liftCek :: forall m s (uni :: Type -> Type) fun a. (PrimMonad m, PrimState m ~ s) => CekM uni fun s a -> m a Source #

Lift a CEK computation to a primitive.PrimMonad m

class Monad m => PrimMonad (m :: Type -> Type) where #

Associated Types

type PrimState (m :: Type -> Type) #

Methods

primitive :: (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a #

Instances

Instances details
PrimMonad IO 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState IO 
Instance details

Defined in Control.Monad.Primitive

Methods

primitive :: (State# (PrimState IO) -> (# State# (PrimState IO), a #)) -> IO a #

PrimMonad (ST s) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ST s) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ST s) = s

Methods

primitive :: (State# (PrimState (ST s)) -> (# State# (PrimState (ST s)), a #)) -> ST s a #

PrimMonad (ST s) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ST s) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ST s) = s

Methods

primitive :: (State# (PrimState (ST s)) -> (# State# (PrimState (ST s)), a #)) -> ST s a #

PrimMonad m => PrimMonad (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type PrimState (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

type PrimState (GenT m) = PrimState m

Methods

primitive :: (State# (PrimState (GenT m)) -> (# State# (PrimState (GenT m)), a #)) -> GenT m a #

PrimMonad m => PrimMonad (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

type PrimState (PropertyT m) = PrimState m

Methods

primitive :: (State# (PrimState (PropertyT m)) -> (# State# (PrimState (PropertyT m)), a #)) -> PropertyT m a #

PrimMonad m => PrimMonad (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

type PrimState (TestT m) = PrimState m

Methods

primitive :: (State# (PrimState (TestT m)) -> (# State# (PrimState (TestT m)), a #)) -> TestT m a #

PrimMonad m => PrimMonad (TreeT m) 
Instance details

Defined in Hedgehog.Internal.Tree

Associated Types

type PrimState (TreeT m) 
Instance details

Defined in Hedgehog.Internal.Tree

type PrimState (TreeT m) = PrimState m

Methods

primitive :: (State# (PrimState (TreeT m)) -> (# State# (PrimState (TreeT m)), a #)) -> TreeT m a #

PrimMonad m => PrimMonad (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Associated Types

type PrimState (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

type PrimState (ResourceT m) = PrimState m

Methods

primitive :: (State# (PrimState (ResourceT m)) -> (# State# (PrimState (ResourceT m)), a #)) -> ResourceT m a #

PrimMonad m => PrimMonad (MaybeT m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (MaybeT m) 
Instance details

Defined in Control.Monad.Primitive

Methods

primitive :: (State# (PrimState (MaybeT m)) -> (# State# (PrimState (MaybeT m)), a #)) -> MaybeT m a #

(Monoid w, PrimMonad m) => PrimMonad (AccumT w m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (AccumT w m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (AccumT w m) = PrimState m

Methods

primitive :: (State# (PrimState (AccumT w m)) -> (# State# (PrimState (AccumT w m)), a #)) -> AccumT w m a #

PrimMonad m => PrimMonad (ExceptT e m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ExceptT e m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ExceptT e m) = PrimState m

Methods

primitive :: (State# (PrimState (ExceptT e m)) -> (# State# (PrimState (ExceptT e m)), a #)) -> ExceptT e m a #

PrimMonad m => PrimMonad (IdentityT m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (IdentityT m) 
Instance details

Defined in Control.Monad.Primitive

Methods

primitive :: (State# (PrimState (IdentityT m)) -> (# State# (PrimState (IdentityT m)), a #)) -> IdentityT m a #

PrimMonad m => PrimMonad (ReaderT r m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ReaderT r m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ReaderT r m) = PrimState m

Methods

primitive :: (State# (PrimState (ReaderT r m)) -> (# State# (PrimState (ReaderT r m)), a #)) -> ReaderT r m a #

PrimMonad m => PrimMonad (SelectT r m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (SelectT r m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (SelectT r m) = PrimState m

Methods

primitive :: (State# (PrimState (SelectT r m)) -> (# State# (PrimState (SelectT r m)), a #)) -> SelectT r m a #

PrimMonad m => PrimMonad (StateT s m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (StateT s m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (StateT s m) = PrimState m

Methods

primitive :: (State# (PrimState (StateT s m)) -> (# State# (PrimState (StateT s m)), a #)) -> StateT s m a #

PrimMonad m => PrimMonad (StateT s m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (StateT s m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (StateT s m) = PrimState m

Methods

primitive :: (State# (PrimState (StateT s m)) -> (# State# (PrimState (StateT s m)), a #)) -> StateT s m a #

(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (WriterT w m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (WriterT w m) = PrimState m

Methods

primitive :: (State# (PrimState (WriterT w m)) -> (# State# (PrimState (WriterT w m)), a #)) -> WriterT w m a #

(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (WriterT w m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (WriterT w m) = PrimState m

Methods

primitive :: (State# (PrimState (WriterT w m)) -> (# State# (PrimState (WriterT w m)), a #)) -> WriterT w m a #

(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (WriterT w m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (WriterT w m) = PrimState m

Methods

primitive :: (State# (PrimState (WriterT w m)) -> (# State# (PrimState (WriterT w m)), a #)) -> WriterT w m a #

PrimMonad (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Associated Types

type PrimState (CekM uni fun s) 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type PrimState (CekM uni fun s) = PrimState (ST s)

Methods

primitive :: (State# (PrimState (CekM uni fun s)) -> (# State# (PrimState (CekM uni fun s)), a #)) -> CekM uni fun s a #

PrimMonad m => PrimMonad (ContT r m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ContT r m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ContT r m) = PrimState m

Methods

primitive :: (State# (PrimState (ContT r m)) -> (# State# (PrimState (ContT r m)), a #)) -> ContT r m a #

(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (RWST r w s m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (RWST r w s m) = PrimState m

Methods

primitive :: (State# (PrimState (RWST r w s m)) -> (# State# (PrimState (RWST r w s m)), a #)) -> RWST r w s m a #

(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (RWST r w s m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (RWST r w s m) = PrimState m

Methods

primitive :: (State# (PrimState (RWST r w s m)) -> (# State# (PrimState (RWST r w s m)), a #)) -> RWST r w s m a #

(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (RWST r w s m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (RWST r w s m) = PrimState m

Methods

primitive :: (State# (PrimState (RWST r w s m)) -> (# State# (PrimState (RWST r w s m)), a #)) -> RWST r w s m a #

lenContext :: forall (uni :: Type -> Type) fun ann. Context uni fun ann -> Word Source #

cekStateContext :: forall (uni :: Type -> Type) fun ann f. Applicative f => (Context uni fun ann -> f (Context uni fun ann)) -> CekState uni fun ann -> f (CekState uni fun ann) Source #

cekStateAnn :: forall (uni :: Type -> Type) fun ann. CekState uni fun ann -> Maybe ann Source #

runCekDeBruijn :: forall (uni :: Type -> Type) fun ann cost. ThrowableBuiltins uni fun => MachineParameters CekMachineCosts fun (CekValue uni fun ann) -> ExBudgetMode cost uni fun -> EmitterMode uni fun -> NTerm uni fun ann -> CekReport cost NamedDeBruijn uni fun Source #

computeCek :: forall (uni :: Type -> Type) fun ann s. (ThrowableBuiltins uni fun, GivenCekReqs uni fun ann s) => Context uni fun ann -> CekValEnv uni fun ann -> NTerm uni fun ann -> CekM uni fun s (CekState uni fun ann) Source #

returnCek :: forall (uni :: Type -> Type) fun ann s. (ThrowableBuiltins uni fun, GivenCekReqs uni fun ann s) => Context uni fun ann -> CekValue uni fun ann -> CekM uni fun s (CekState uni fun ann) Source #

mkCekTrans :: forall cost (uni :: Type -> Type) fun ann m s. (ThrowableBuiltins uni fun, PrimMonad m, s ~ PrimState m) => MachineParameters CekMachineCosts fun (CekValue uni fun ann) -> ExBudgetMode cost uni fun -> EmitterMode uni fun -> Slippage -> m (CekTrans uni fun ann s, ExBudgetInfo cost uni fun s) Source #

Based on the supplied arguments, initialize the CEK environment and construct a state transition function. Returns the constructed transition function paired with the methods to live access the running budget.

type CekTrans (uni :: Type -> Type) fun ann s = Trans (CekM uni fun s) (CekState uni fun ann) Source #

nilSlippage :: Slippage Source #

A CEK parameter that turns the slippage optimization *off*.

This is needed in the case of the debugger, where the accounting/budgeting costs must be *live* updated.

data EvaluationResult a Source #

The parameterized type of results various evaluation engines return.

Instances

Instances details
MonadFail EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Foldable EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

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

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

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

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

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

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

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

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

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

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

null :: EvaluationResult a -> Bool Source #

length :: EvaluationResult a -> Int Source #

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

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

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

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

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

Traversable EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Alternative EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Applicative EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Functor EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Monad EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

MonadError () EvaluationResult Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

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 :: Type) 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Methods

typeAst :: Type tyname uni () Source #

(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

(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

PrettyBy config a => PrettyBy config (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

prettyBy :: config -> EvaluationResult a -> Doc ann #

prettyListBy :: config -> [EvaluationResult a] -> Doc ann #

Generic (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Associated Types

type Rep (EvaluationResult a) 
Instance details

Defined in PlutusCore.Evaluation.Result

type Rep (EvaluationResult a) = D1 ('MetaData "EvaluationResult" "PlutusCore.Evaluation.Result" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "EvaluationSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "EvaluationFailure" 'PrefixI 'False) (U1 :: Type -> Type))
Show a => Show (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

NFData a => NFData (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

rnf :: EvaluationResult a -> () Source #

Eq a => Eq (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

PrettyClassic a => Pretty (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

pretty :: EvaluationResult a -> Doc ann #

prettyList :: [EvaluationResult a] -> Doc ann #

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

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (EvaluationResult a :: Type) = ToBinds uni acc a
type ToHoles uni _1 (EvaluationResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni _1 (EvaluationResult a :: Type) = '[TypeHole a :: Hole]
type IsBuiltin uni (EvaluationResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type Rep (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Evaluation.Result

type Rep (EvaluationResult a) = D1 ('MetaData "EvaluationResult" "PlutusCore.Evaluation.Result" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "EvaluationSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "EvaluationFailure" 'PrefixI 'False) (U1 :: Type -> Type))

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

StructuralError !structural 
OperationalError !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) 
Instance details

Defined in PlutusCore.Evaluation.Error

type Rep (EvaluationError structural operational) = D1 ('MetaData "EvaluationError" "PlutusCore.Evaluation.Error" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "StructuralError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 structural)) :+: C1 ('MetaCons "OperationalError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 operational)))

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 #

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

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.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "StructuralError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 structural)) :+: C1 ('MetaCons "OperationalError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 operational)))

data ErrorWithCause err cause Source #

An error and (optionally) what caused it.

Constructors

ErrorWithCause 

Fields

Instances

Instances details
Bifunctor ErrorWithCause Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

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

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

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

(PrettyBy config cause, PrettyBy config err) => PrettyBy config (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

prettyBy :: config -> ErrorWithCause err cause -> Doc ann #

prettyListBy :: config -> [ErrorWithCause err cause] -> Doc ann #

Foldable (ErrorWithCause err) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

fold :: Monoid m => ErrorWithCause err m -> m Source #

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

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

foldr :: (a -> b -> b) -> b -> ErrorWithCause err a -> b Source #

foldr' :: (a -> b -> b) -> b -> ErrorWithCause err a -> b Source #

foldl :: (b -> a -> b) -> b -> ErrorWithCause err a -> b Source #

foldl' :: (b -> a -> b) -> b -> ErrorWithCause err a -> b Source #

foldr1 :: (a -> a -> a) -> ErrorWithCause err a -> a Source #

foldl1 :: (a -> a -> a) -> ErrorWithCause err a -> a Source #

toList :: ErrorWithCause err a -> [a] Source #

null :: ErrorWithCause err a -> Bool Source #

length :: ErrorWithCause err a -> Int Source #

elem :: Eq a => a -> ErrorWithCause err a -> Bool Source #

maximum :: Ord a => ErrorWithCause err a -> a Source #

minimum :: Ord a => ErrorWithCause err a -> a Source #

sum :: Num a => ErrorWithCause err a -> a Source #

product :: Num a => ErrorWithCause err a -> a Source #

Traversable (ErrorWithCause err) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

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

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

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

sequence :: Monad m => ErrorWithCause err (m a) -> m (ErrorWithCause err a) Source #

Functor (ErrorWithCause err) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

fmap :: (a -> b) -> ErrorWithCause err a -> ErrorWithCause err b Source #

(<$) :: a -> ErrorWithCause err b -> ErrorWithCause err a Source #

(PrettyPlc cause, PrettyPlc err, Typeable cause, Typeable err) => Exception (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Generic (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Associated Types

type Rep (ErrorWithCause err cause) 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

type Rep (ErrorWithCause err cause) = D1 ('MetaData "ErrorWithCause" "PlutusCore.Evaluation.ErrorWithCause" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "ErrorWithCause" 'PrefixI 'True) (S1 ('MetaSel ('Just "_ewcError") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 err) :*: S1 ('MetaSel ('Just "_ewcCause") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe cause))))

Methods

from :: ErrorWithCause err cause -> Rep (ErrorWithCause err cause) x Source #

to :: Rep (ErrorWithCause err cause) x -> ErrorWithCause err cause Source #

(PrettyPlc cause, PrettyPlc err) => Show (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

showsPrec :: Int -> ErrorWithCause err cause -> ShowS Source #

show :: ErrorWithCause err cause -> String Source #

showList :: [ErrorWithCause err cause] -> ShowS Source #

(NFData err, NFData cause) => NFData (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

rnf :: ErrorWithCause err cause -> () Source #

(Eq err, Eq cause) => Eq (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

(==) :: ErrorWithCause err cause -> ErrorWithCause err cause -> Bool Source #

(/=) :: ErrorWithCause err cause -> ErrorWithCause err cause -> Bool Source #

(Pretty err, Pretty cause) => Pretty (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

Methods

pretty :: ErrorWithCause err cause -> Doc ann #

prettyList :: [ErrorWithCause err cause] -> Doc ann #

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 (ErrorWithCause err cause) Source # 
Instance details

Defined in PlutusCore.Evaluation.ErrorWithCause

type Rep (ErrorWithCause err cause) = D1 ('MetaData "ErrorWithCause" "PlutusCore.Evaluation.ErrorWithCause" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "ErrorWithCause" 'PrefixI 'True) (S1 ('MetaSel ('Just "_ewcError") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 err) :*: S1 ('MetaSel ('Just "_ewcCause") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe cause))))

splitStructuralOperational :: Either (EvaluationException structural operational term) a -> Either (ErrorWithCause structural term) (EvaluationResult a) Source #

Preserve the contents of an StructuralError as a Left and turn an OperationalError into a Right EvaluationFailure (thus erasing the content of the error in the latter case).

unsafeSplitStructuralOperational :: (PrettyPlc structural, PrettyPlc term, Typeable structural, Typeable term) => Either (EvaluationException structural operational term) a -> EvaluationResult a Source #

Throw on a StructuralError and turn an OperationalError into an EvaluationFailure (thus erasing the content of the error in the latter case).

type ThrowableBuiltins (uni :: Type -> Type) fun = (PrettyUni uni, Pretty fun, Typeable uni, Typeable fun) Source #

The set of constraints we need to be able to throw exceptions with things with built-in types and functions in them.

data CekUserError Source #

Constructors

CekCaseBuiltinError Text

Case over a value of a built-in type failed.

CekOutOfExError !ExRestrictingBudget

The final overspent (i.e. negative) budget.

CekEvaluationFailure

Error has been called or a builtin application has failed

Instances

Instances details
Generic CekUserError Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Associated Types

type Rep CekUserError 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep CekUserError = D1 ('MetaData "CekUserError" "UntypedPlutusCore.Evaluation.Machine.Cek.Internal" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "CekCaseBuiltinError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "CekOutOfExError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ExRestrictingBudget)) :+: C1 ('MetaCons "CekEvaluationFailure" 'PrefixI 'False) (U1 :: Type -> Type)))
Show CekUserError Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

NFData CekUserError Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

rnf :: CekUserError -> () Source #

Eq CekUserError Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Pretty CekUserError Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

pretty :: CekUserError -> Doc ann #

prettyList :: [CekUserError] -> Doc ann #

BuiltinErrorToEvaluationError (MachineError fun) CekUserError Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

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

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep CekUserError = D1 ('MetaData "CekUserError" "UntypedPlutusCore.Evaluation.Machine.Cek.Internal" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "CekCaseBuiltinError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "CekOutOfExError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ExRestrictingBudget)) :+: C1 ('MetaCons "CekEvaluationFailure" 'PrefixI 'False) (U1 :: Type -> Type)))

type CekEvaluationException name (uni :: Type -> Type) fun = EvaluationException (MachineError fun) CekUserError (Term name uni fun ()) Source #

The CEK machine-specific EvaluationException.

data ExBudgetCategory fun Source #

Constructors

BStep StepKind 
BBuiltinApp fun 
BStartup 

Instances

Instances details
ExBudgetBuiltin fun (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Generic (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Associated Types

type Rep (ExBudgetCategory fun) 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep (ExBudgetCategory fun) = D1 ('MetaData "ExBudgetCategory" "UntypedPlutusCore.Evaluation.Machine.Cek.Internal" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "BStep" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StepKind)) :+: (C1 ('MetaCons "BBuiltinApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 fun)) :+: C1 ('MetaCons "BStartup" 'PrefixI 'False) (U1 :: Type -> Type)))
Show fun => Show (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

NFData fun => NFData (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

rnf :: ExBudgetCategory fun -> () Source #

Eq fun => Eq (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Ord fun => Ord (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Hashable fun => Hashable (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Show fun => Pretty (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

pretty :: ExBudgetCategory fun -> Doc ann #

prettyList :: [ExBudgetCategory fun] -> Doc ann #

type Rep (ExBudgetCategory fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep (ExBudgetCategory fun) = D1 ('MetaData "ExBudgetCategory" "UntypedPlutusCore.Evaluation.Machine.Cek.Internal" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (C1 ('MetaCons "BStep" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StepKind)) :+: (C1 ('MetaCons "BBuiltinApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 fun)) :+: C1 ('MetaCons "BStartup" 'PrefixI 'False) (U1 :: Type -> Type)))

newtype CekBudgetSpender (uni :: Type -> Type) fun s Source #

The CEK machine is parameterized over a spendBudget function. This makes the budgeting machinery extensible and allows us to separate budgeting logic from evaluation logic and avoid branching on the union of all possible budgeting state types during evaluation.

Constructors

CekBudgetSpender 

Fields

newtype ExBudgetMode cost (uni :: Type -> Type) fun Source #

A budgeting mode to execute the CEK machine in.

Constructors

ExBudgetMode 

Fields

data StepKind Source #

Instances

Instances details
Bounded StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Enum StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Generic StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Associated Types

type Rep StepKind 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep StepKind = D1 ('MetaData "StepKind" "UntypedPlutusCore.Evaluation.Machine.Cek.Internal" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (((C1 ('MetaCons "BConst" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BVar" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BLamAbs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BApply" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "BDelay" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BForce" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BBuiltin" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BConstr" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BCase" 'PrefixI 'False) (U1 :: Type -> Type)))))
Show StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

NFData StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

rnf :: StepKind -> () Source #

Eq StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Ord StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Hashable StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep StepKind Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type Rep StepKind = D1 ('MetaData "StepKind" "UntypedPlutusCore.Evaluation.Machine.Cek.Internal" "plutus-core-1.60.0.0-LXFqBsoUlXsJIEqLytHte7" 'False) (((C1 ('MetaCons "BConst" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BVar" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BLamAbs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BApply" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "BDelay" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BForce" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BBuiltin" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BConstr" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BCase" 'PrefixI 'False) (U1 :: Type -> Type)))))

data CekResult name (uni :: Type -> Type) fun Source #

The result of evaluating a term with the CEK machine.

Constructors

CekFailure (CekEvaluationException name uni fun) 
CekSuccessConstant (Some (ValueOf uni)) 
CekSuccessNonConstant (Term name uni fun ()) 

data CekReport cost name (uni :: Type -> Type) fun Source #

All info produced by a CEK machine run.

Constructors

CekReport 

Fields

cekResultToEither :: forall name (uni :: Type -> Type) fun. CekResult name uni fun -> Either (CekEvaluationException name uni fun) (Term name uni fun ()) Source #

Convert the given CekResult into an Either. This is useful, because in the ledger API we care whether the result is a constant or not, but in tests, executables etc we don't and so handling an either-error-or-term is more natural.

data CekValue (uni :: Type -> Type) fun ann Source #

Constructors

VCon !(Some (ValueOf uni)) 
VDelay !(NTerm uni fun ann) !(CekValEnv uni fun ann) 
VLamAbs !NamedDeBruijn !(NTerm uni fun ann) !(CekValEnv uni fun ann) 
VBuiltin

A partial builtin application, accumulating arguments for eventual full application. We don't need a CekValEnv here unlike in the other constructors, because VBuiltin values always store their corresponding Terms fully discharged, see the comments at the call sites (search for VBuiltin).

Fields

  • !fun

    So that we know, for what builtin we're calculating the cost. We can sneak this into BuiltinRuntime, so that we don't need to store it here, but somehow doing so was consistently slowing evaluation down by half a percent. Might be noise, might be not, but at least we know that removing this fun is not helpful anyway. See this commit reversing the change: https://github.com/IntersectMBO/plutus/pull/4778/commits/86a3e24ca3c671cc27c6f4344da2bcd14f961706

  • (NTerm uni fun ())

    This must be lazy. It represents the fully discharged partial application of the builtin function that we're going to run when it's fully saturated. We need the Term to be able to return it in case full saturation is never achieved and a partial application needs to be returned in the result. The laziness is important, because the arguments are discharged values and discharging is expensive, so we don't want to do it unless we really have to. Making this field strict resulted in a 3-4.5% slowdown at the time of writing.

  • !(BuiltinRuntime (CekValue uni fun ann))

    The partial application and its costing function. Check the docs of BuiltinRuntime for details. | A constructor value, including fully computed arguments and the tag.

VConstr !Word64 !(EmptyOrMultiStack uni fun ann) 

Instances

Instances details
(PrettyUni uni, Pretty fun) => PrettyBy PrettyConfigPlc (CekValue uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

prettyBy :: PrettyConfigPlc -> CekValue uni fun ann -> Doc ann0 #

prettyListBy :: PrettyConfigPlc -> [CekValue uni fun ann] -> Doc ann0 #

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 #

(GShow uni, Everywhere uni Show, Show fun, Show ann, Closed uni) => Show (CekValue uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

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

show :: CekValue uni fun ann -> String Source #

showList :: [CekValue uni fun ann] -> ShowS 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 #

(Closed uni, Everywhere uni ExMemoryUsage) => ExMemoryUsage (CekValue uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

memoryUsage :: CekValue uni fun ann -> CostRose Source #

type UniOf (CekValue uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type UniOf (CekValue uni fun ann) = uni

data DischargeResult (uni :: Type -> Type) fun Source #

The result of dischargeCekValue.

Constructors

DischargeConstant (Some (ValueOf uni)) 
DischargeNonConstant (NTerm uni fun ()) 

Instances

Instances details
(PrettyUni uni, Pretty fun) => PrettyBy PrettyConfigPlc (DischargeResult uni fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

prettyBy :: PrettyConfigPlc -> DischargeResult uni fun -> Doc ann #

prettyListBy :: PrettyConfigPlc -> [DischargeResult uni fun] -> Doc ann #

(GShow uni, Everywhere uni Show, Show fun, Closed uni) => Show (DischargeResult uni fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

(GEq uni, Everywhere uni Eq, Eq fun, Closed uni) => Eq (DischargeResult uni fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

(==) :: DischargeResult uni fun -> DischargeResult uni fun -> Bool Source #

(/=) :: DischargeResult uni fun -> DischargeResult uni fun -> Bool Source #

dischargeResultToTerm :: forall (uni :: Type -> Type) fun. DischargeResult uni fun -> NTerm uni fun () Source #

newtype EmitterMode (uni :: Type -> Type) fun Source #

An emitting mode to execute the CEK machine in, similar to ExBudgetMode.

Constructors

EmitterMode 

Fields

mapTermCekResult :: forall name (uni :: Type -> Type) fun name'. (Term name uni fun () -> Term name' uni fun ()) -> CekResult name uni fun -> CekResult name' uni fun Source #

Apply the given function to the Term (if any) stored in the given CekResult.

data ArgStack (uni :: Type -> Type) fun ann Source #

A LIFO stack of CekValues, used to record multiple arguments that need to be pushed onto the context in reverse order. Currently used by FrameConstr for collecting the elements of a Constr as it is cheap to prepend new elements in ArgStack.

Constructors

NilStack 
ConsStack !(CekValue uni fun ann) !(ArgStack uni fun ann) 

Instances

Instances details
(GShow uni, Everywhere uni Show, Show fun, Show ann, Closed uni) => Show (ArgStack uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

showsPrec :: Int -> ArgStack uni fun ann -> ShowS Source #

show :: ArgStack uni fun ann -> String Source #

showList :: [ArgStack uni fun ann] -> ShowS Source #

data EmptyOrMultiStack (uni :: Type -> Type) fun ann Source #

An alternative version of ArgStack that uses ArgNonEmptyStack when non-empty. Used in VConstr. Once all evaluated elements of Constr is collecting to ArgStack in FrameConstr, the collected elements gets reversed and put into VConstr as EmptyOrMultiStack. VConstr using EmptyOrMultiStack is more efficient than ArgStack when casing, since FrameAwaitFunValueN can be dispatched with a single pattern match.

Constructors

EmptyStack 
MultiStack !(ArgStackNonEmpty uni fun ann) 

Instances

Instances details
(GShow uni, Everywhere uni Show, Show fun, Show ann, Closed uni) => Show (EmptyOrMultiStack uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

showsPrec :: Int -> EmptyOrMultiStack uni fun ann -> ShowS Source #

show :: EmptyOrMultiStack uni fun ann -> String Source #

showList :: [EmptyOrMultiStack uni fun ann] -> ShowS Source #

data ArgStackNonEmpty (uni :: Type -> Type) fun ann Source #

A non-empty variant of ArgStack, used in FrameAwaitFunValueN to store arguments that will be applied to a term. More efficient than ArgStack, since this saves one evaluation cycle by ensuring there is no NilStack.

Constructors

LastStackNonEmpty !(CekValue uni fun ann) 
ConsStackNonEmpty !(CekValue uni fun ann) !(ArgStackNonEmpty uni fun ann) 

Instances

Instances details
(GShow uni, Everywhere uni Show, Show fun, Show ann, Closed uni) => Show (ArgStackNonEmpty uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

showsPrec :: Int -> ArgStackNonEmpty uni fun ann -> ShowS Source #

show :: ArgStackNonEmpty uni fun ann -> String Source #

showList :: [ArgStackNonEmpty uni fun ann] -> ShowS Source #

data ExBudgetInfo cost (uni :: Type -> Type) fun s Source #

Runtime budgeting info.

Constructors

ExBudgetInfo 

Fields

type CekEmitter (uni :: Type -> Type) fun s = DList Text -> CekM uni fun s () Source #

The CEK machine is parameterized over an emitter function, similar to CekBudgetSpender.

data CekEmitterInfo (uni :: Type -> Type) fun s Source #

Runtime emitter info, similar to ExBudgetInfo.

Constructors

CekEmitterInfo 

Fields

newtype CekM (uni :: Type -> Type) fun s a Source #

The monad the CEK machine runs in.

Constructors

CekM 

Fields

Instances

Instances details
Applicative (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

pure :: a -> CekM uni fun s a Source #

(<*>) :: CekM uni fun s (a -> b) -> CekM uni fun s a -> CekM uni fun s b Source #

liftA2 :: (a -> b -> c) -> CekM uni fun s a -> CekM uni fun s b -> CekM uni fun s c Source #

(*>) :: CekM uni fun s a -> CekM uni fun s b -> CekM uni fun s b Source #

(<*) :: CekM uni fun s a -> CekM uni fun s b -> CekM uni fun s a Source #

Functor (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

fmap :: (a -> b) -> CekM uni fun s a -> CekM uni fun s b Source #

(<$) :: a -> CekM uni fun s b -> CekM uni fun s a Source #

Monad (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

(>>=) :: CekM uni fun s a -> (a -> CekM uni fun s b) -> CekM uni fun s b Source #

(>>) :: CekM uni fun s a -> CekM uni fun s b -> CekM uni fun s b Source #

return :: a -> CekM uni fun s a Source #

PrimMonad (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Associated Types

type PrimState (CekM uni fun s) 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type PrimState (CekM uni fun s) = PrimState (ST s)

Methods

primitive :: (State# (PrimState (CekM uni fun s)) -> (# State# (PrimState (CekM uni fun s)), a #)) -> CekM uni fun s a #

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 PrimState (CekM uni fun s) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

type PrimState (CekM uni fun s) = PrimState (ST s)

dischargeCekValue :: forall (uni :: Type -> Type) fun ann. CekValue uni fun ann -> DischargeResult uni fun Source #

Convert a CekValue into a Term by replacing all bound variables with the terms they're bound to (which themselves have to be obtained by recursively discharging values).

type CekValEnv (uni :: Type -> Type) fun ann = RAList (CekValue uni fun ann) Source #

type GivenCekReqs (uni :: Type -> Type) fun ann s = (GivenCekRuntime uni fun ann, GivenCekCaserBuiltin uni, GivenCekEmitter uni fun s, GivenCekSpender uni fun s, GivenCekSlippage, GivenCekStepCounter s, GivenCekCosts) Source #

Constraint requiring all of the machine's implicit parameters.

type GivenCekSpender (uni :: Type -> Type) fun s = ?cekBudgetSpender :: CekBudgetSpender uni fun s Source #

Implicit parameter for budget spender.

data StepCounter (n :: Nat) s Source #

A set of Word8 counters that is used in the CEK machine to count steps.

type NumberOfStepCounters = CountConstructorsEnum (Rep StepKind) Source #

The number of step counters that we need, should be the same as the number of constructors of StepKind.

type CounterSize = NumberOfStepCounters + 1 Source #

The total number of counters that we need, one extra for the total counter. See Note [Structure of the step counter]

type TotalCountIndex = NumberOfStepCounters Source #

The index at which the total step counter is kept. See Note [Structure of the step counter]

defaultSlippage :: Slippage Source #

The default number of slippage (in machine steps) to allow.

type NTerm (uni :: Type -> Type) fun = Term NamedDeBruijn uni fun Source #

The Terms that CEK can execute must have DeBruijn binders Name is not necessary but we leave it here for simplicity and debuggability.

runCekM :: forall cost (uni :: Type -> Type) fun ann. ThrowableBuiltins uni fun => MachineParameters CekMachineCosts fun (CekValue uni fun ann) -> ExBudgetMode cost uni fun -> EmitterMode uni fun -> (forall s. GivenCekReqs uni fun ann s => CekM uni fun s (DischargeResult uni fun)) -> CekReport cost NamedDeBruijn uni fun Source #