Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
PlutusCore.Builtin.KnownType
Synopsis
- data BuiltinError
- 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
- data Spine a
- data HeadSpine a
- class uni ~ UniOf val ⇒ MakeKnownIn uni val a where
- makeKnown ∷ a → BuiltinResult (HeadSpine 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 (HeadSpine val)
- readKnownSelf ∷ (ReadKnown val a, BuiltinErrorToEvaluationError structural operational) ⇒ val → Either (ErrorWithCause (EvaluationError structural operational) 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 Methods (==) ∷ BuiltinError → BuiltinError → Bool Source # (/=) ∷ BuiltinError → BuiltinError → Bool Source # | |
Pretty BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result | |
MonadError BuiltinError BuiltinResult Source # |
|
Defined in PlutusCore.Builtin.Result Methods throwError ∷ BuiltinError → BuiltinResult a Source # catchError ∷ BuiltinResult a → (BuiltinError → BuiltinResult a) → BuiltinResult a Source # |
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.
Constructors
BuiltinSuccess a | |
BuiltinSuccessWithLogs (DList Text) a | |
BuiltinFailure (DList Text) BuiltinError |
Instances
type ReadKnownM = Either BuiltinError Source #
The monad that readKnown
runs in.
A non-empty spine. Isomorphic to NonEmpty
, except is strict and is defined as a single
recursive data type.
Instances
The head-spine form of an iterated application. Provides O(1) access to the head of the
application. Isomorphic to NonEmpty
, except is strict and the no-spine case is made a separate
constructor for performance reasons (it only takes a single pattern match to access the head when
there's no spine this way, while otherwise we'd also need to match on the spine to ensure that
it's empty -- and the no-spine case is by far the most common one, hence we want to optimize it).
Used in built-in functions returning function applications such as CaseList
.
Instances
class uni ~ UniOf val ⇒ MakeKnownIn uni val a where Source #
Minimal complete definition
Nothing
Methods
makeKnown ∷ a → BuiltinResult (HeadSpine val) Source #
Convert a Haskell value to the corresponding PLC value.
The inverse of readKnown
.
default makeKnown ∷ KnownBuiltinType val a ⇒ a → BuiltinResult (HeadSpine 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 #
Minimal complete definition
Nothing
Methods
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 (HeadSpine val) Source #
Same as makeKnown
, but allows for neither emitting nor storing the cause of a failure.
readKnownSelf ∷ (ReadKnown val a, BuiltinErrorToEvaluationError structural operational) ⇒ val → Either (ErrorWithCause (EvaluationError structural operational) val) a Source #
Same as readKnown
, but the cause of a potential failure is the provided term itself.