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

PlutusCore.Evaluation.Error

Description

The exceptions that an abstract machine can throw.

Synopsis

Documentation

data EvaluationError operational structural Source #

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

  1. 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.
  2. 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, or a non-function was applied to an argument.

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, operational errors are regular runtime errors and structural errors are "runtime type 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. For example, a built-in function expecting a list but getting something else should throw a structural error, but currently it'll throw an operational one. This is something that we plan to improve upon in future.

Constructors

OperationalEvaluationError !operational 
StructuralEvaluationError !structural 

Instances

Instances details
Bifoldable EvaluationError Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

bifoldMonoid m ⇒ EvaluationError m m → m Source #

bifoldMapMonoid 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

bitraverseApplicative f ⇒ (a → f c) → (b → f d) → EvaluationError a b → f (EvaluationError c d) Source #

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

Defined in PlutusCore.Evaluation.Error

Methods

prettyBy ∷ config → EvaluationError operational structural → Doc ann Source #

prettyListBy ∷ config → [EvaluationError operational structural] → Doc ann Source #

Functor (EvaluationError operational) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

fmap ∷ (a → b) → EvaluationError operational a → EvaluationError operational b Source #

(<$) ∷ a → EvaluationError operational b → EvaluationError operational a Source #

Generic (EvaluationError operational structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Associated Types

type Rep (EvaluationError operational structural) ∷ TypeType Source #

Methods

fromEvaluationError operational structural → Rep (EvaluationError operational structural) x Source #

toRep (EvaluationError operational structural) x → EvaluationError operational structural Source #

(Show operational, Show structural) ⇒ Show (EvaluationError operational structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

showsPrecIntEvaluationError operational structural → ShowS Source #

showEvaluationError operational structural → String Source #

showList ∷ [EvaluationError operational structural] → ShowS Source #

(NFData operational, NFData structural) ⇒ NFData (EvaluationError operational structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

rnfEvaluationError operational structural → () Source #

(Eq operational, Eq structural) ⇒ Eq (EvaluationError operational structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

(==)EvaluationError operational structural → EvaluationError operational structural → Bool Source #

(/=)EvaluationError operational structural → EvaluationError operational structural → Bool Source #

(AsUnliftingError operational, AsUnliftingError structural) ⇒ AsUnliftingEvaluationError (EvaluationError operational structural) Source #

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

Instance details

Defined in PlutusCore.Builtin.Result

AsEvaluationFailure operational ⇒ AsEvaluationFailure (EvaluationError operational structural) Source #

A raw evaluation failure is always an operational error.

Instance details

Defined in PlutusCore.Evaluation.Error

Methods

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

(Pretty operational, Pretty structural) ⇒ Pretty (EvaluationError operational structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

Methods

prettyEvaluationError operational structural → Doc ann #

prettyList ∷ [EvaluationError operational structural] → Doc ann #

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

Defined in PlutusCore.Evaluation.Machine.Exception

Methods

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

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

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

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

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

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

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

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

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

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

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

Defined in PlutusCore.Evaluation.Error

Methods

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

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

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

ThrowableBuiltins uni fun ⇒ MonadError (CekEvaluationException NamedDeBruijn uni fun) (CekM uni fun s) 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

throwErrorCekEvaluationException NamedDeBruijn uni fun → CekM uni fun s a

catchErrorCekM uni fun s a → (CekEvaluationException NamedDeBruijn uni fun → CekM uni fun s a) → CekM uni fun s a

type Rep (EvaluationError operational structural) Source # 
Instance details

Defined in PlutusCore.Evaluation.Error

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

class AsEvaluationError r operational structural | r → operational structural where Source #

Minimal complete definition

_EvaluationError

Methods

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

_OperationalEvaluationError ∷ Prism' r operational Source #

_StructuralEvaluationError ∷ Prism' r structural Source #

Instances

Instances details
AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # 
Instance details

Defined in PlutusCore.Builtin.Result

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

Defined in PlutusCore.Evaluation.Error

Methods

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

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

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