Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- 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
- newtype UnliftingError = MkUnliftingError {}
- newtype UnliftingEvaluationError = MkUnliftingEvaluationError {}
- data BuiltinError
- data BuiltinResult a
- class AsUnliftingEvaluationError r where
- class AsUnliftingError r where
- _UnliftingError ∷ Prism' r UnliftingError
- _MkUnliftingError ∷ Prism' r Text
- class AsBuiltinError r where
- _BuiltinError ∷ Prism' r BuiltinError
- _BuiltinUnliftingEvaluationError ∷ Prism' r UnliftingEvaluationError
- _BuiltinEvaluationFailure ∷ Prism' r ()
- class AsBuiltinResult r a | r → a where
- _BuiltinResult ∷ Prism' r (BuiltinResult a)
- _BuiltinSuccess ∷ Prism' r a
- _BuiltinSuccessWithLogs ∷ Prism' r (DList Text, a)
- _BuiltinFailure ∷ Prism' r (DList Text, BuiltinError)
- _UnliftingErrorVia ∷ Pretty err ⇒ err → Prism' err UnliftingError
- _StructuralUnliftingError ∷ AsBuiltinError err ⇒ Prism' err UnliftingError
- _OperationalUnliftingError ∷ AsBuiltinError err ⇒ Prism' err UnliftingError
- throwNotAConstant ∷ MonadError BuiltinError m ⇒ m void
- throwUnderTypeError ∷ MonadError BuiltinError m ⇒ m void
- emit ∷ Text → BuiltinResult ()
- withLogs ∷ DList Text → BuiltinResult a → BuiltinResult a
- throwing ∷ MonadError e m ⇒ AReview e t → t → m x
- throwing_ ∷ MonadError e m ⇒ AReview e () → m x
Documentation
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 # |
newtype UnliftingError Source #
The error message part of an UnliftingEvaluationError
.
Instances
newtype UnliftingEvaluationError Source #
When unlifting of a PLC term into a Haskell value fails, this error is thrown.
Instances
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 BuiltinResult a Source #
The monad that makeKnown
runs in.
Equivalent to ExceptT BuiltinError (Writer (DList Text))
, except optimized in two ways:
- everything is strict
- 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
class AsUnliftingEvaluationError r where Source #
_UnliftingEvaluationError ∷ Prism' r UnliftingEvaluationError Source #
_MkUnliftingEvaluationError ∷ Prism' r (EvaluationError UnliftingError UnliftingError) Source #
Instances
AsUnliftingEvaluationError BuiltinError Source # | |
AsUnliftingEvaluationError UnliftingEvaluationError Source # | |
(AsUnliftingError structural, AsUnliftingError operational) ⇒ AsUnliftingEvaluationError (EvaluationError structural operational) Source # | An |
Defined in PlutusCore.Builtin.Result _UnliftingEvaluationError ∷ Prism' (EvaluationError structural operational) UnliftingEvaluationError Source # _MkUnliftingEvaluationError ∷ Prism' (EvaluationError structural operational) (EvaluationError UnliftingError UnliftingError) Source # |
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 # |
class AsBuiltinError r where Source #
_BuiltinError ∷ Prism' r BuiltinError Source #
_BuiltinUnliftingEvaluationError ∷ Prism' r UnliftingEvaluationError Source #
_BuiltinEvaluationFailure ∷ Prism' r () Source #
Instances
AsBuiltinError BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result _BuiltinError ∷ Prism' BuiltinError BuiltinError Source # _BuiltinUnliftingEvaluationError ∷ Prism' BuiltinError UnliftingEvaluationError Source # _BuiltinEvaluationFailure ∷ Prism' BuiltinError () Source # |
class AsBuiltinResult r a | r → a where Source #
_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
AsBuiltinResult (BuiltinResult a) a Source # | |
Defined in PlutusCore.Builtin.Result _BuiltinResult ∷ Prism' (BuiltinResult a) (BuiltinResult a) Source # _BuiltinSuccess ∷ Prism' (BuiltinResult a) a Source # _BuiltinSuccessWithLogs ∷ Prism' (BuiltinResult a) (DList Text, a) Source # _BuiltinFailure ∷ Prism' (BuiltinResult a) (DList Text, BuiltinError) Source # |
_UnliftingErrorVia ∷ Pretty err ⇒ err → Prism' err UnliftingError Source #
Construct a prism focusing on the *EvaluationFailure
part of err
by taking
that *EvaluationFailure
and
- pretty-printing and embedding it into an
UnliftingError
for the setter part of the prism - 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
.
_StructuralUnliftingError ∷ AsBuiltinError err ⇒ Prism' err UnliftingError Source #
_OperationalUnliftingError ∷ AsBuiltinError err ⇒ Prism' err UnliftingError Source #
throwNotAConstant ∷ MonadError BuiltinError m ⇒ m void Source #
throwUnderTypeError ∷ MonadError BuiltinError m ⇒ m void Source #
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 #