Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data BuiltinError
- throwBuiltinErrorWithCause ∷ (MonadError (ErrorWithCause err cause) m, AsUnliftingEvaluationError err, AsEvaluationFailure err) ⇒ cause → BuiltinError → m void
- type KnownBuiltinTypeIn uni val a = (HasConstantIn uni val, PrettyParens (SomeTypeIn uni), GEq uni, uni `HasTermLevel` a)
- type KnownBuiltinType val a = KnownBuiltinTypeIn (UniOf val) val a
- data BuiltinResult a
- type ReadKnownM = Either BuiltinError
- class uni ~ UniOf val ⇒ MakeKnownIn uni val a where
- makeKnown ∷ a → BuiltinResult val
- readKnownConstant ∷ ∀ val a. KnownBuiltinType val a ⇒ val → ReadKnownM a
- type MakeKnown val = MakeKnownIn (UniOf val) val
- class uni ~ UniOf val ⇒ ReadKnownIn uni val a where
- readKnown ∷ val → ReadKnownM a
- type ReadKnown val = ReadKnownIn (UniOf val) val
- makeKnownOrFail ∷ MakeKnownIn uni val a ⇒ a → EvaluationResult val
- readKnownSelf ∷ (ReadKnown val a, AsUnliftingEvaluationError err, AsEvaluationFailure err) ⇒ val → Either (ErrorWithCause err val) a
Documentation
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 # |
throwBuiltinErrorWithCause ∷ (MonadError (ErrorWithCause err cause) m, AsUnliftingEvaluationError err, AsEvaluationFailure err) ⇒ cause → BuiltinError → m void Source #
Attach a cause
to a BuiltinError
and throw that.
Note that an evaluator might require the cause to be computed lazily for best performance on the
happy path, hence this function must not force its first argument.
TODO: wrap cause
in Lazy
once we have it.
type KnownBuiltinTypeIn uni val a = (HasConstantIn uni val, PrettyParens (SomeTypeIn uni), GEq uni, uni `HasTermLevel` a) Source #
A constraint for "a
is a ReadKnownIn
and MakeKnownIn
by means of being included
in uni
".
type KnownBuiltinType val a = KnownBuiltinTypeIn (UniOf val) val a Source #
A constraint for "a
is a ReadKnownIn
and MakeKnownIn
by means of being included
in UniOf term
".
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
type ReadKnownM = Either BuiltinError Source #
The monad that readKnown
runs in.
class uni ~ UniOf val ⇒ MakeKnownIn uni val a where Source #
Nothing
makeKnown ∷ a → BuiltinResult val Source #
Convert a Haskell value to the corresponding PLC value.
The inverse of readKnown
.
default makeKnown ∷ KnownBuiltinType val a ⇒ a → BuiltinResult val Source #
Instances
readKnownConstant ∷ ∀ val a. KnownBuiltinType val a ⇒ val → ReadKnownM a Source #
Convert a constant embedded into a PLC term to the corresponding Haskell value.
type MakeKnown val = MakeKnownIn (UniOf val) val Source #
class uni ~ UniOf val ⇒ ReadKnownIn uni val a where Source #
Nothing
readKnown ∷ val → ReadKnownM a Source #
Convert a PLC value to the corresponding Haskell value.
The inverse of makeKnown
.
default readKnown ∷ KnownBuiltinType val a ⇒ val → ReadKnownM a Source #
Instances
type ReadKnown val = ReadKnownIn (UniOf val) val Source #
makeKnownOrFail ∷ MakeKnownIn uni val a ⇒ a → EvaluationResult val Source #
Same as makeKnown
, but allows for neither emitting nor storing the cause of a failure.
readKnownSelf ∷ (ReadKnown val a, AsUnliftingEvaluationError err, AsEvaluationFailure err) ⇒ val → Either (ErrorWithCause err val) a Source #
Same as readKnown
, but the cause of a potential failure is the provided term itself.