Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The exceptions that an abstract machine can throw.
Synopsis
- newtype UnliftingError = MkUnliftingError {}
- class AsUnliftingError r where
- _UnliftingError ∷ Prism' r UnliftingError
- _MkUnliftingError ∷ Prism' r Text
- data BuiltinError
- data MachineError fun
- = NonPolymorphicInstantiationMachineError
- | NonWrapUnwrappedMachineError
- | NonFunctionalApplicationMachineError
- | OpenTermEvaluatedMachineError
- | UnliftingMachineError UnliftingError
- | BuiltinTermArgumentExpectedMachineError
- | UnexpectedBuiltinTermArgumentMachineError
- | NonConstrScrutinized
- | MissingCaseBranch Word64
- class AsMachineError r fun | r → fun where
- _MachineError ∷ Prism' r (MachineError fun)
- _NonPolymorphicInstantiationMachineError ∷ Prism' r ()
- _NonWrapUnwrappedMachineError ∷ Prism' r ()
- _NonFunctionalApplicationMachineError ∷ Prism' r ()
- _OpenTermEvaluatedMachineError ∷ Prism' r ()
- _UnliftingMachineError ∷ Prism' r UnliftingError
- _BuiltinTermArgumentExpectedMachineError ∷ Prism' r ()
- _UnexpectedBuiltinTermArgumentMachineError ∷ Prism' r ()
- _NonConstrScrutinized ∷ Prism' r ()
- _MissingCaseBranch ∷ Prism' r Word64
- data EvaluationError structural operational
- = StructuralEvaluationError !structural
- | OperationalEvaluationError !operational
- class AsEvaluationError r structural operational | r → structural operational where
- _EvaluationError ∷ Prism' r (EvaluationError structural operational)
- _StructuralEvaluationError ∷ Prism' r structural
- _OperationalEvaluationError ∷ Prism' r operational
- data ErrorWithCause err cause = ErrorWithCause {}
- type EvaluationException structural operational = ErrorWithCause (EvaluationError structural operational)
- throwNotAConstant ∷ MonadError BuiltinError m ⇒ m void
- throwing ∷ MonadError e m ⇒ AReview e t → t → m x
- throwing_ ∷ MonadError e m ⇒ AReview e () → m x
- throwingWithCause ∷ ∀ exc e t term m x. (exc ~ ErrorWithCause e term, MonadError exc m) ⇒ AReview e t → t → Maybe term → m x
- splitStructuralOperational ∷ Either (EvaluationException structural operational term) a → Either (ErrorWithCause structural term) (EvaluationResult a)
- unsafeSplitStructuralOperational ∷ (PrettyPlc structural, PrettyPlc term, Typeable structural, Typeable term) ⇒ Either (EvaluationException structural operational term) a → EvaluationResult a
Documentation
newtype UnliftingError Source #
The error message part of an UnliftingEvaluationError
.
Instances
class AsUnliftingError r where Source #
_UnliftingError ∷ Prism' r UnliftingError Source #
_MkUnliftingError ∷ Prism' r Text Source #
Instances
AsUnliftingError UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result _UnliftingError ∷ Prism' UnliftingError UnliftingError Source # _MkUnliftingError ∷ Prism' UnliftingError Text Source # | |
AsUnliftingError CekUserError Source # | |
Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal _UnliftingError ∷ Prism' CekUserError UnliftingError Source # _MkUnliftingError ∷ Prism' CekUserError Text Source # | |
AsUnliftingError (MachineError fun) Source # | |
Defined in PlutusCore.Evaluation.Machine.Exception _UnliftingError ∷ Prism' (MachineError fun) UnliftingError Source # _MkUnliftingError ∷ Prism' (MachineError fun) Text Source # |
data BuiltinError Source #
The type of errors that readKnown
and makeKnown
can return.
Instances
Show BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result | |
Eq BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result (==) ∷ BuiltinError → BuiltinError → Bool Source # (/=) ∷ BuiltinError → BuiltinError → Bool Source # | |
AsBuiltinError BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result _BuiltinError ∷ Prism' BuiltinError BuiltinError Source # _BuiltinUnliftingEvaluationError ∷ Prism' BuiltinError UnliftingEvaluationError Source # _BuiltinEvaluationFailure ∷ Prism' BuiltinError () Source # | |
AsUnliftingEvaluationError BuiltinError Source # | |
AsEvaluationFailure BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result _EvaluationFailure ∷ Prism' BuiltinError () Source # | |
Pretty BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result pretty ∷ BuiltinError → Doc ann Source # prettyList ∷ [BuiltinError] → Doc ann Source # | |
MonadError BuiltinError BuiltinResult Source # |
|
Defined in PlutusCore.Builtin.Result throwError ∷ BuiltinError → BuiltinResult a Source # catchError ∷ BuiltinResult a → (BuiltinError → BuiltinResult a) → BuiltinResult a Source # |
data MachineError fun Source #
Errors which can occur during a run of an abstract machine.
NonPolymorphicInstantiationMachineError | An attempt to reduce a not immediately reducible type instantiation. |
NonWrapUnwrappedMachineError | An attempt to unwrap a not wrapped term. |
NonFunctionalApplicationMachineError | An attempt to reduce a not immediately reducible application. |
OpenTermEvaluatedMachineError | An attempt to evaluate an open term. |
UnliftingMachineError UnliftingError | An attempt to compute a constant application resulted in |
BuiltinTermArgumentExpectedMachineError | A builtin expected a term argument, but something else was received. |
UnexpectedBuiltinTermArgumentMachineError | A builtin received a term argument when something else was expected |
NonConstrScrutinized | |
MissingCaseBranch Word64 |
Instances
class AsMachineError r fun | r → fun where Source #
_MachineError ∷ Prism' r (MachineError fun) Source #
_NonPolymorphicInstantiationMachineError ∷ Prism' r () Source #
_NonWrapUnwrappedMachineError ∷ Prism' r () Source #
_NonFunctionalApplicationMachineError ∷ Prism' r () Source #
_OpenTermEvaluatedMachineError ∷ Prism' r () Source #
_UnliftingMachineError ∷ Prism' r UnliftingError Source #
_BuiltinTermArgumentExpectedMachineError ∷ Prism' r () Source #
_UnexpectedBuiltinTermArgumentMachineError ∷ Prism' r () Source #
_NonConstrScrutinized ∷ Prism' r () Source #
_MissingCaseBranch ∷ Prism' r Word64 Source #
Instances
data EvaluationError structural operational Source #
The type of errors that can occur during evaluation. There are two kinds of errors:
- 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. - 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.
StructuralEvaluationError !structural | |
OperationalEvaluationError !operational |
Instances
class AsEvaluationError r structural operational | r → structural operational where Source #
_EvaluationError ∷ Prism' r (EvaluationError structural operational) Source #
_StructuralEvaluationError ∷ Prism' r structural Source #
_OperationalEvaluationError ∷ Prism' r operational Source #
Instances
AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result | |
AsEvaluationError (EvaluationError structural operational) structural operational Source # | |
Defined in PlutusCore.Evaluation.Error _EvaluationError ∷ Prism' (EvaluationError structural operational) (EvaluationError structural operational) Source # _StructuralEvaluationError ∷ Prism' (EvaluationError structural operational) structural Source # _OperationalEvaluationError ∷ Prism' (EvaluationError structural operational) operational Source # |
data ErrorWithCause err cause Source #
An error and (optionally) what caused it.
Instances
type EvaluationException structural operational = ErrorWithCause (EvaluationError structural operational) Source #
throwNotAConstant ∷ MonadError BuiltinError m ⇒ m void Source #
throwing ∷ MonadError e m ⇒ AReview e t → t → m x #
throwing_ ∷ MonadError e m ⇒ AReview e () → m x #
throwingWithCause ∷ ∀ exc e t term m x. (exc ~ ErrorWithCause e term, MonadError exc m) ⇒ AReview e t → t → Maybe term → m x Source #
Prismatically throw an error and its (optional) cause.
splitStructuralOperational ∷ Either (EvaluationException structural operational term) a → Either (ErrorWithCause structural term) (EvaluationResult a) Source #
Preserve the contents of an StructuralEvaluationError
as a Left
and turn an
OperationalEvaluationError
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 StructuralEvaluationError
and turn an OperationalEvaluationError
into an
EvaluationFailure
(thus erasing the content of the error in the latter case).