Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Reexports from modules from the Builtin
folder.
Synopsis
- class Typeable (a :: k)
- data TypeScheme val (args :: [Type]) res where
- TypeSchemeResult :: (Typeable res, KnownTypeAst TyName (UniOf val) res, MakeKnown val res) => TypeScheme val '[] res
- TypeSchemeArrow :: (Typeable arg, KnownTypeAst TyName (UniOf val) arg, MakeKnown val arg, ReadKnown val arg) => TypeScheme val args res -> TypeScheme val (arg ': args) res
- TypeSchemeAll :: (KnownSymbol text, KnownNat uniq, KnownKind kind) => Proxy '(text, uniq, kind) -> TypeScheme val args res -> TypeScheme val args res
- argProxy :: TypeScheme val (arg ': args) res -> Proxy arg
- typeSchemeToType :: TypeScheme val args res -> Type TyName (UniOf val) ()
- class (uni `Everywhere` ImplementedKnownTypeAst uni, uni `Everywhere` ImplementedReadKnownIn uni, uni `Everywhere` ImplementedMakeKnownIn uni) => TestTypesFromTheUniverseAreAllKnown uni
- data BuiltinRuntime val
- = BuiltinCostedResult ExBudgetStream ~(BuiltinResult val)
- | BuiltinExpectArgument (val -> BuiltinRuntime val)
- | BuiltinExpectForce (BuiltinRuntime val)
- data BuiltinsRuntime fun val = BuiltinsRuntime {
- unBuiltinsRuntime :: fun -> BuiltinRuntime val
- builtinRuntimeFailure :: BuiltinError -> BuiltinRuntime val
- lookupBuiltin :: fun -> BuiltinsRuntime fun val -> BuiltinRuntime val
- 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
- = BuiltinSuccess a
- | BuiltinSuccessWithLogs (DList Text) a
- | BuiltinFailure (DList Text) BuiltinError
- class AsUnliftingEvaluationError r where
- _UnliftingEvaluationError :: Prism' r UnliftingEvaluationError
- _MkUnliftingEvaluationError :: Prism' r (EvaluationError UnliftingError UnliftingError)
- 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
- newtype Opaque val (rep :: Type) = Opaque {
- unOpaque :: val
- newtype SomeConstant uni (rep :: Type) = SomeConstant {
- unSomeConstant :: Some (ValueOf uni)
- data TyNameRep (kind :: Type) = TyNameRep Symbol Nat
- data family TyVarRep (name :: TyNameRep kind) :: kind
- data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod
- data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type
- data family BuiltinHead x
- type family ElaborateBuiltin uni x
- type family AllElaboratedArgs constr x where ...
- class AllElaboratedArgs constr (ElaborateBuiltin uni x) => AllBuiltinArgs uni constr x
- type family FoldArgs args res where ...
- data BuiltinMeaning val cost = forall args res. BuiltinMeaning (TypeScheme val args res) ~(FoldArgs args res) (cost -> BuiltinRuntime val)
- type HasMeaningIn uni val = (Typeable val, ExMemoryUsage val, HasConstantIn uni val)
- class (Typeable uni, Typeable fun, Bounded fun, Enum fun, Ix fun, Default (BuiltinSemanticsVariant fun)) => ToBuiltinMeaning uni fun where
- type CostingPart uni fun
- data BuiltinSemanticsVariant fun
- toBuiltinMeaning :: HasMeaningIn uni val => BuiltinSemanticsVariant fun -> fun -> BuiltinMeaning val (CostingPart uni fun)
- withTypeSchemeOfBuiltinFunction :: forall val fun r. (ToBuiltinMeaning (UniOf val) fun, ExMemoryUsage val, Typeable val, HasConstant val) => BuiltinSemanticsVariant fun -> fun -> (forall args res. TypeScheme val args res -> r) -> r
- typeOfBuiltinFunction :: forall uni fun. ToBuiltinMeaning uni fun => BuiltinSemanticsVariant fun -> fun -> Type TyName uni ()
- type family GetArgs a where ...
- class KnownMonotype val args res where
- knownMonotype :: TypeScheme val args res
- toMonoF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val
- class KnownMonotype val args res => KnownPolytype (binds :: [Some TyNameRep]) val args res where
- knownPolytype :: TypeScheme val args res
- toPolyF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val
- type family ThrowOnBothEmpty binds args isBuiltin a where ...
- class MakeBuiltinMeaning a val where
- makeBuiltinMeaning :: a -> (cost -> FoldArgs (GetArgs a) ExBudgetStream) -> BuiltinMeaning val cost
- toBuiltinRuntime :: cost -> BuiltinMeaning val cost -> BuiltinRuntime val
- toBuiltinsRuntime :: (cost ~ CostingPart uni fun, ToBuiltinMeaning uni fun, HasMeaningIn uni val) => BuiltinSemanticsVariant fun -> cost -> BuiltinsRuntime fun val
- data TyNameRep (kind :: Type) = TyNameRep Symbol Nat
- data family TyVarRep (name :: TyNameRep kind) :: kind
- data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod
- data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type
- data Hole
- data family RepHole x
- type HasTermLevel uni = Includes uni
- type HasTypeLevel uni x = KnownTypeAst Void uni (ElaborateBuiltin uni x)
- type HasTypeAndTermLevel uni x = (uni `HasTypeLevel` x, uni `HasTermLevel` x)
- mkTyBuiltin :: forall a (x :: a) uni ann tyname. uni `HasTypeLevel` x => ann -> Type tyname uni ann
- data family TypeHole a
- type KnownBuiltinTypeAst tyname uni x = AllBuiltinArgs uni (KnownTypeAst tyname uni) x
- class KnownTypeAst tyname uni x where
- toTypeAst :: forall a tyname uni (x :: a) proxy. KnownTypeAst tyname uni x => proxy x -> Type tyname uni ()
- type family Insert x xs where ...
- type family Delete x xs where ...
- 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
- = BuiltinSuccess a
- | BuiltinSuccessWithLogs (DList Text) a
- | BuiltinFailure (DList Text) BuiltinError
- type ReadKnownM = Either BuiltinError
- class uni ~ UniOf val => MakeKnownIn uni val a where
- makeKnown :: a -> BuiltinResult val
- readKnownConstant :: forall 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
- data SingKind k where
- withSingKind :: Kind ann -> (forall k. SingKind k -> r) -> r
- class KnownKind k where
- bringKnownKind :: SingKind k -> (KnownKind k => r) -> r
- withKnownKind :: Kind ann -> (forall k. KnownKind k => Proxy k -> r) -> r
- class ToKind (uni :: Type -> Type) where
- toSingKind :: uni (Esc (a :: k)) -> SingKind k
- demoteKind :: SingKind k -> Kind ()
- kindOfBuiltinType :: ToKind uni => uni (Esc a) -> Kind ()
- data BuiltinError
- throwNotAConstant :: MonadError BuiltinError m => m void
- class HasConstant term where
- asConstant :: term -> Either BuiltinError (Some (ValueOf (UniOf term)))
- fromConstant :: Some (ValueOf (UniOf term)) -> term
- type HasConstantIn uni term = (UniOf term ~ uni, HasConstant term)
- fromValueOf :: forall a term. HasConstant term => UniOf term (Esc a) -> a -> term
- fromValue :: forall a term. (HasConstant term, UniOf term `HasTermLevel` a) => a -> term
Documentation
class Typeable (a :: k) Source #
The class Typeable
allows a concrete representation of a type to
be calculated.
typeRep#
data TypeScheme val (args :: [Type]) res where Source #
The type of type schemes of built-in functions.
args
is a list of types of arguments, res
is the resulting type.
E.g. Text -> Bool -> Integer
is encoded as TypeScheme val [Text, Bool] Integer
.
TypeSchemeResult :: (Typeable res, KnownTypeAst TyName (UniOf val) res, MakeKnown val res) => TypeScheme val '[] res | |
TypeSchemeArrow :: (Typeable arg, KnownTypeAst TyName (UniOf val) arg, MakeKnown val arg, ReadKnown val arg) => TypeScheme val args res -> TypeScheme val (arg ': args) res infixr 9 | |
TypeSchemeAll :: (KnownSymbol text, KnownNat uniq, KnownKind kind) => Proxy '(text, uniq, kind) -> TypeScheme val args res -> TypeScheme val args res |
Instances
Show (TypeScheme val args res) Source # | |
Defined in PlutusCore.Builtin.TypeScheme |
argProxy :: TypeScheme val (arg ': args) res -> Proxy arg Source #
typeSchemeToType :: TypeScheme val args res -> Type TyName (UniOf val) () Source #
Convert a TypeScheme
to the corresponding Kind
.
class (uni `Everywhere` ImplementedKnownTypeAst uni, uni `Everywhere` ImplementedReadKnownIn uni, uni `Everywhere` ImplementedMakeKnownIn uni) => TestTypesFromTheUniverseAreAllKnown uni Source #
An instance of this class not having any constraints ensures that every type (according to
Everywhere
) from the universe has 'KnownTypeAst, ReadKnownIn
and MakeKnownIn
instances.
Instances
data BuiltinRuntime val Source #
A BuiltinRuntime
represents a possibly partial builtin application, including an empty
builtin application (i.e. just the builtin with no arguments).
Applying or type-instantiating a builtin peels off the corresponding constructor from its
BuiltinRuntime
.
BuiltinCostedResult
contains the cost (an ExBudget
) and the result (a BuiltinResult val
) of
the builtin application. The cost is stored strictly, since the evaluator is going to look at it
and the result is stored lazily, since it's not supposed to be forced before accounting for the
cost of the application. If the cost exceeds the available budget, the evaluator discards the
result of the builtin application without ever forcing it and terminates with evaluation
failure. Allowing the user to compute something that they don't have the budget for would be a
major bug.
Evaluators that ignore the entire concept of costing (e.g. the CK machine) may of course force the result of the builtin application unconditionally.
BuiltinCostedResult ExBudgetStream ~(BuiltinResult val) | |
BuiltinExpectArgument (val -> BuiltinRuntime val) | |
BuiltinExpectForce (BuiltinRuntime val) |
Instances
Show (BuiltinRuntime (CkValue uni fun)) Source # | |
Defined in PlutusCore.Evaluation.Machine.Ck | |
Show (BuiltinRuntime (CekValue uni fun ann)) Source # | |
NFData (BuiltinRuntime val) Source # | |
Defined in PlutusCore.Builtin.Runtime rnf :: BuiltinRuntime val -> () Source # | |
NoThunks (BuiltinRuntime val) Source # | |
Defined in PlutusCore.Builtin.Runtime noThunks :: Context -> BuiltinRuntime val -> IO (Maybe ThunkInfo) wNoThunks :: Context -> BuiltinRuntime val -> IO (Maybe ThunkInfo) showTypeOf :: Proxy (BuiltinRuntime val) -> String |
data BuiltinsRuntime fun val Source #
A data
wrapper around a function returning the BuiltinRuntime
of a built-in function.
We use data
rather than newtype
, because GHC is able to see through newtype
s and may break
carefully set up optimizations, see
https://github.com/IntersectMBO/plutus/pull/4914#issuecomment-1396306606
Using data
may make things more expensive, however it was verified at the time of writing that
the wrapper is removed before the CEK machine starts, leaving the stored function to be used
directly.
In order for lookups to be efficient the BuiltinRuntime
s need to be cached, i.e. pulled out
of the function statically. See makeBuiltinMeaning
for how we achieve that.
BuiltinsRuntime | |
|
Instances
(Bounded fun, Enum fun) => NFData (BuiltinsRuntime fun val) Source # | |
Defined in PlutusCore.Builtin.Runtime rnf :: BuiltinsRuntime fun val -> () Source # | |
(Bounded fun, Enum fun) => NoThunks (BuiltinsRuntime fun val) Source # | |
Defined in PlutusCore.Builtin.Runtime noThunks :: Context -> BuiltinsRuntime fun val -> IO (Maybe ThunkInfo) wNoThunks :: Context -> BuiltinsRuntime fun val -> IO (Maybe ThunkInfo) showTypeOf :: Proxy (BuiltinsRuntime fun val) -> String |
builtinRuntimeFailure :: BuiltinError -> BuiltinRuntime val Source #
lookupBuiltin :: fun -> BuiltinsRuntime fun val -> BuiltinRuntime val Source #
Look up the runtime info of a built-in function during evaluation.
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
Show UnliftingEvaluationError Source # | |
Defined in PlutusCore.Builtin.Result | |
NFData UnliftingEvaluationError Source # | |
Defined in PlutusCore.Builtin.Result rnf :: UnliftingEvaluationError -> () Source # | |
Eq UnliftingEvaluationError Source # | |
Defined in PlutusCore.Builtin.Result | |
AsUnliftingEvaluationError UnliftingEvaluationError Source # | |
Pretty UnliftingEvaluationError Source # | |
Defined in PlutusCore.Builtin.Result pretty :: UnliftingEvaluationError -> Doc ann # prettyList :: [UnliftingEvaluationError] -> Doc ann # | |
AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result |
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 # prettyList :: [BuiltinError] -> Doc ann # | |
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.
BuiltinSuccess a | |
BuiltinSuccessWithLogs (DList Text) a | |
BuiltinFailure (DList Text) BuiltinError |
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 #
newtype Opaque val (rep :: Type) Source #
The AST of a value with a Plutus type attached to it. The type is for the Plutus type checker
to look at. Opaque
can appear in the type of the denotation of a builtin.
Instances
newtype SomeConstant uni (rep :: Type) Source #
For unlifting from the Constant
constructor when the stored value is of a monomorphic
built-in type
The rep
parameter specifies how the type looks on the PLC side (i.e. just like with
Opaque val rep
).
SomeConstant | |
|
Instances
data TyNameRep (kind :: Type) Source #
Representation of a type variable: its name and unique and an implicit kind.
Instances
data family TyVarRep (name :: TyNameRep kind) :: kind Source #
Representation of an intrinsically-kinded type variable: a name.
Instances
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst tyname uni (TyVarRep name :: a) Source # | |
(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # | |
type ToBinds uni acc (TyVarRep name :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (TyVarRep name :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type ToHoles uni (TyVarRep name :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst |
data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #
Representation of an intrinsically-kinded type application: a function and an argument.
Instances
(KnownTypeAst tyname uni fun, KnownTypeAst tyname uni arg) => KnownTypeAst tyname uni (TyAppRep fun arg :: a) Source # | |
type ToBinds uni acc (TyAppRep fun arg :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (TyAppRep fun arg :: a) Source # | |
type ToHoles uni (TyAppRep fun arg :: a) Source # | |
data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #
Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.
Instances
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst type IsBuiltin uni (TyForallRep name a) :: Bool Source # type ToHoles uni (TyForallRep name a) :: [Hole] Source # type ToBinds uni acc (TyForallRep name a) :: [Some TyNameRep] Source # | |
type ToBinds uni acc (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type ToHoles uni (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst |
data family BuiltinHead x Source #
For annotating an uninstantiated built-in type, so that it gets handled by the right instance or type family.
Instances
Contains uni f => KnownTypeAst tyname uni (BuiltinHead f :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst type IsBuiltin uni (BuiltinHead f) :: Bool Source # type ToHoles uni (BuiltinHead f) :: [Hole] Source # type ToBinds uni acc (BuiltinHead f) :: [Some TyNameRep] Source # | |
type ToBinds uni acc (BuiltinHead f :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (BuiltinHead f :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type ToHoles uni (BuiltinHead f :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst |
type family ElaborateBuiltin uni x Source #
Take an iterated application of a built-in type and elaborate every function application
inside of it to TyAppRep
and annotate the head with BuiltinHead
.
The idea is that we don't need to process built-in types manually if we simply add some
annotations for instance resolution to look for. Think what we'd have to do manually for, say,
ToHoles
: traverse the spine of the application and collect all the holes into a list, which is
troubling, because type applications are left-nested and lists are right-nested, so we'd have to
use accumulators or an explicit Reverse
type family. And then we also have KnownTypeAst
and
ToBinds
, so handling built-in types in a special way for each of those would be a hassle,
especially given the fact that type-level Haskell is not exactly good at computing things.
With the ElaborateBuiltin
approach we get KnownTypeAst
, ToHoles
and ToBinds
for free.
We make this an open type family, so that elaboration is customizable for each universe.
Instances
type ElaborateBuiltin DefaultUni (x :: a) Source # | |
Defined in PlutusCore.Default.Universe |
type family AllElaboratedArgs constr x where ... Source #
Take a constraint and use it to constrain every argument of a possibly 0-ary elaborated application of a built-in type.
AllElaboratedArgs constr (f `TyAppRep` x) = (constr x, AllElaboratedArgs constr f) | |
AllElaboratedArgs _ (BuiltinHead _) = () |
class AllElaboratedArgs constr (ElaborateBuiltin uni x) => AllBuiltinArgs uni constr x Source #
Take a constraint and use it to constrain every argument of a possibly 0-ary application of a built-in type.
Instances
AllElaboratedArgs constr (ElaborateBuiltin uni x) => AllBuiltinArgs uni constr (x :: a) Source # | |
Defined in PlutusCore.Builtin.Polymorphism |
type family FoldArgs args res where ... Source #
Turn a list of Haskell types args
into a functional type ending in res
.
>>>
:set -XDataKinds
>>>
:kind! FoldArgs [(), Bool] Integer
FoldArgs [(), Bool] Integer :: * = () -> Bool -> Integer
data BuiltinMeaning val cost Source #
The meaning of a built-in function consists of its type represented as a TypeScheme
,
its Haskell denotation and its uninstantiated runtime denotation.
The TypeScheme
of a built-in function is used for example for
- computing the PLC type of the function to be used during type checking
- getting arity information
- generating arbitrary values to apply the function to in tests
The denotation is lazy, so that we don't need to worry about a builtin being bottom (happens in tests). The production path is not affected by that, since only runtime denotations are used for evaluation.
forall args res. BuiltinMeaning (TypeScheme val args res) ~(FoldArgs args res) (cost -> BuiltinRuntime val) |
type HasMeaningIn uni val = (Typeable val, ExMemoryUsage val, HasConstantIn uni val) Source #
Constraints available when defining a built-in function.
class (Typeable uni, Typeable fun, Bounded fun, Enum fun, Ix fun, Default (BuiltinSemanticsVariant fun)) => ToBuiltinMeaning uni fun where Source #
A type class for "each function from a set of built-in functions has a BuiltinMeaning
".
type CostingPart uni fun Source #
The cost
part of BuiltinMeaning
.
data BuiltinSemanticsVariant fun Source #
See Note [Builtin semantics variants]
toBuiltinMeaning :: HasMeaningIn uni val => BuiltinSemanticsVariant fun -> fun -> BuiltinMeaning val (CostingPart uni fun) Source #
Get the BuiltinMeaning
of a built-in function.
Instances
withTypeSchemeOfBuiltinFunction :: forall val fun r. (ToBuiltinMeaning (UniOf val) fun, ExMemoryUsage val, Typeable val, HasConstant val) => BuiltinSemanticsVariant fun -> fun -> (forall args res. TypeScheme val args res -> r) -> r Source #
Feed the TypeScheme
of the given built-in function to the continuation.
typeOfBuiltinFunction :: forall uni fun. ToBuiltinMeaning uni fun => BuiltinSemanticsVariant fun -> fun -> Type TyName uni () Source #
Get the type of a built-in function.
class KnownMonotype val args res where Source #
A class that allows us to derive a monotype for a builtin.
We could've computed the runtime denotation from the
TypeScheme
and the denotation of the builtin, but not statically (due to unfolding not working
for recursive functions and TypeScheme
being recursive, i.e. requiring the conversion function
to be recursive), and so it would cause us to retain a lot of evaluation-irrelevant stuff in the
constructors of BuiltinRuntime
, which has to make evaluation slower (we didn't check) and
certainly makes the generated Core much harder to read. Technically speaking, we could get
a RuntimeScheme
from the TypeScheme
and the denotation statically if we changed the
definition of TypeScheme
and made it a singleton, but then the conversion function would have
to become a class anyway and we'd just replicate what we have here, except in a much more
complicated way.
knownMonotype :: TypeScheme val args res Source #
toMonoF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val Source #
Convert the denotation of a builtin to its runtime counterpart .
The argument is in ReadKnownM
, because that's what deferred unlifting amounts to:
passing the action returning the builtin application around until full saturation, which is
when the action actually gets run.
Instances
(Typeable res, KnownTypeAst TyName (UniOf val) res, MakeKnown val res) => KnownMonotype val ('[] :: [Type]) res Source # | Once we've run out of term-level arguments, we return a
|
Defined in PlutusCore.Builtin.Meaning knownMonotype :: TypeScheme val '[] res Source # toMonoF :: ReadKnownM (FoldArgs '[] res, FoldArgs '[] ExBudgetStream) -> BuiltinRuntime val Source # | |
(Typeable arg, KnownTypeAst TyName (UniOf val) arg, MakeKnown val arg, ReadKnown val arg, KnownMonotype val args res) => KnownMonotype val (arg ': args) res Source # | Every term-level argument becomes a |
Defined in PlutusCore.Builtin.Meaning knownMonotype :: TypeScheme val (arg ': args) res Source # toMonoF :: ReadKnownM (FoldArgs (arg ': args) res, FoldArgs (arg ': args) ExBudgetStream) -> BuiltinRuntime val Source # |
class KnownMonotype val args res => KnownPolytype (binds :: [Some TyNameRep]) val args res where Source #
A class that allows us to derive a polytype for a builtin.
knownPolytype :: TypeScheme val args res Source #
toPolyF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val Source #
Convert the denotation of a builtin to its runtime counterpart.
The argument is in ReadKnownM
, because that's what we need to do:
passing the action returning the builtin application around until full saturation, which is
when the action actually gets run.
Instances
KnownMonotype val args res => KnownPolytype ('[] :: [Some TyNameRep]) val args res Source # | Once we've run out of type-level arguments, we start handling term-level ones. |
Defined in PlutusCore.Builtin.Meaning knownPolytype :: TypeScheme val args res Source # toPolyF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val Source # | |
(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res Source # | Every type-level argument becomes a |
Defined in PlutusCore.Builtin.Meaning knownPolytype :: TypeScheme val args res Source # toPolyF :: ReadKnownM (FoldArgs args res, FoldArgs args ExBudgetStream) -> BuiltinRuntime val Source # |
type family ThrowOnBothEmpty binds args isBuiltin a where ... Source #
Ensure a built-in function is not nullary and throw a nice error otherwise.
ThrowOnBothEmpty '[] '[] 'True a = TypeError (('Text "A built-in function must take at least one type or term argument" ':$$: ((('Text "\8216" ':<>: 'ShowType a) ':<>: 'Text "\8217 is a built-in type") ':<>: 'Text " so you can embed any of its values as a constant")) ':$$: 'Text "If you still want a built-in function, add a dummy \8216()\8217 argument") | |
ThrowOnBothEmpty '[] '[] 'False a = TypeError ('Text "A built-in function must take at least one type or term argument" ':$$: 'Text "To fix this error add a dummy \8216()\8217 argument") | |
ThrowOnBothEmpty _ _ _ _ = () |
class MakeBuiltinMeaning a val where Source #
A function turned into a type class with exactly one fully general instance.
We can't package up the constraints of makeBuiltinMeaning
(see the instance) into a type or
class synonym, because they contain a bunch of variables defined by ~
or determined via
functional dependencies and neither class nor type definitions can handle that
(see https://gitlab.haskell.org/ghc/ghc/-/issues/7100). Inlining three lines of constraints
whenever we need to call makeBuiltinMeaning
over a non-concrete type is a bad option and this
abstraction is free anyway, hence its existence.
The a
type variable goes first, because makeBuiltinMeaning @A
is a common pattern.
makeBuiltinMeaning :: a -> (cost -> FoldArgs (GetArgs a) ExBudgetStream) -> BuiltinMeaning val cost Source #
Construct the meaning for a built-in function by automatically deriving its
TypeScheme
, given
- the denotation of the builtin
- an uninstantiated costing function
Instances
(uni ~ UniOf val, binds ~ ToBinds uni ('[] :: [Some TyNameRep]) a, args ~ GetArgs a, a ~ FoldArgs args res, ThrowOnBothEmpty binds args (IsBuiltin uni a) a, ElaborateFromTo uni 0 j val a, KnownPolytype binds val args res) => MakeBuiltinMeaning a val Source # | |
Defined in PlutusCore.Builtin.Meaning makeBuiltinMeaning :: a -> (cost -> FoldArgs (GetArgs a) ExBudgetStream) -> BuiltinMeaning val cost Source # |
toBuiltinRuntime :: cost -> BuiltinMeaning val cost -> BuiltinRuntime val Source #
Convert a BuiltinMeaning
to a BuiltinRuntime
given a cost model.
toBuiltinsRuntime :: (cost ~ CostingPart uni fun, ToBuiltinMeaning uni fun, HasMeaningIn uni val) => BuiltinSemanticsVariant fun -> cost -> BuiltinsRuntime fun val Source #
Calculate runtime info for all built-in functions given meanings of builtins (as a constraint), the semantics variant of the set of builtins and a cost model.
data TyNameRep (kind :: Type) Source #
Representation of a type variable: its name and unique and an implicit kind.
Instances
data family TyVarRep (name :: TyNameRep kind) :: kind Source #
Representation of an intrinsically-kinded type variable: a name.
Instances
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst tyname uni (TyVarRep name :: a) Source # | |
(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # | |
type ToBinds uni acc (TyVarRep name :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (TyVarRep name :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type ToHoles uni (TyVarRep name :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst |
data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #
Representation of an intrinsically-kinded type application: a function and an argument.
Instances
(KnownTypeAst tyname uni fun, KnownTypeAst tyname uni arg) => KnownTypeAst tyname uni (TyAppRep fun arg :: a) Source # | |
type ToBinds uni acc (TyAppRep fun arg :: a) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (TyAppRep fun arg :: a) Source # | |
type ToHoles uni (TyAppRep fun arg :: a) Source # | |
data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #
Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.
Instances
(tyname ~ TyName, name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst tyname uni a) => KnownTypeAst tyname uni (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst type IsBuiltin uni (TyForallRep name a) :: Bool Source # type ToHoles uni (TyForallRep name a) :: [Hole] Source # type ToBinds uni acc (TyForallRep name a) :: [Some TyNameRep] Source # | |
type ToBinds uni acc (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type IsBuiltin uni (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst | |
type ToHoles uni (TyForallRep name a :: Type) Source # | |
Defined in PlutusCore.Builtin.KnownTypeAst |
type HasTermLevel uni = Includes uni Source #
Specifies that the given type is a built-in one and its values can be embedded into a Term
.
type HasTypeLevel uni x = KnownTypeAst Void uni (ElaborateBuiltin uni x) Source #
Specifies that the given type is a built-in one and can be embedded into a Kind
.
type HasTypeAndTermLevel uni x = (uni `HasTypeLevel` x, uni `HasTermLevel` x) Source #
The product of HasTypeLevel
and HasTermLevel
.
mkTyBuiltin :: forall a (x :: a) uni ann tyname. uni `HasTypeLevel` x => ann -> Type tyname uni ann Source #
Convert a Haskell representation of a possibly 0-ary application of a built-in type to
arbitrary types implementing KnownTypeAst
.
type KnownBuiltinTypeAst tyname uni x = AllBuiltinArgs uni (KnownTypeAst tyname uni) x Source #
A constraint for "a
is a KnownTypeAst
by means of being included in uni
".
class KnownTypeAst tyname uni x where Source #
This class allows one to convert the type-level Haskell representation of a Plutus type into the corresponding Plutus type. Associated type families are needed to help elaboration.
Depending on the universe converting a Haskell type to a Plutus team can give different results
(e.g. Int
can be a built-in type instead of being encoded via built-in Integer
), hence this
class takes a uni
argument. Plus, elaboration is universe-specific too.
Nothing
type IsBuiltin uni x :: Bool Source #
Whether x
is a built-in type.
type IsBuiltin uni x = IsBuiltin uni (ElaborateBuiltin uni x)
type ToHoles uni x :: [Hole] Source #
Return every part of the type that can be a to-be-instantiated type variable.
For example, in Integer
there's no such types and in (a, b)
it's the two arguments
(a
and b
) and the same applies to a -> b
(to mention a type that is not built-in).
type ToHoles uni x = ToHoles uni (ElaborateBuiltin uni x)
type ToBinds uni (acc :: [Some TyNameRep]) x :: [Some TyNameRep] Source #
Collect all unique variables (a variable consists of a textual name, a unique and a kind) in an accumulator and return the accumulator once a leaf is reached.
type ToBinds uni acc x = ToBinds uni acc (ElaborateBuiltin uni x)
typeAst :: Type tyname uni () Source #
The Plutus counterpart of the x
type.
default typeAst :: KnownTypeAst tyname uni (ElaborateBuiltin uni x) => Type tyname uni () Source #
Instances
toTypeAst :: forall a tyname uni (x :: a) proxy. KnownTypeAst tyname uni x => proxy x -> Type tyname uni () Source #
Return the Plutus counterpart of the x
type.
type family Delete x xs where ... Source #
Delete the first x
from a list. Which is okay since we only ever put things in once.
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 # prettyList :: [BuiltinError] -> Doc ann # | |
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.
BuiltinSuccess a | |
BuiltinSuccessWithLogs (DList Text) a | |
BuiltinFailure (DList Text) BuiltinError |
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 :: forall 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.
withSingKind :: Kind ann -> (forall k. SingKind k -> r) -> r Source #
class KnownKind k where Source #
For reifying Haskell kinds representing Plutus kinds at the term level.
bringKnownKind :: SingKind k -> (KnownKind k => r) -> r Source #
class ToKind (uni :: Type -> Type) where Source #
For computing the Plutus kind of a built-in type. See kindOfBuiltinType
.
toSingKind :: uni (Esc (a :: k)) -> SingKind k Source #
Reify the kind of a type from the universe at the term level.
Instances
ToKind DefaultUni Source # | |
Defined in PlutusCore.Default.Universe toSingKind :: forall k (a :: k). DefaultUni (Esc a) -> SingKind k Source # |
demoteKind :: SingKind k -> Kind () Source #
Convert a reified Haskell kind to a Plutus kind.
kindOfBuiltinType :: ToKind uni => uni (Esc a) -> Kind () Source #
Compute the kind of a type from a universe.
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 # prettyList :: [BuiltinError] -> Doc ann # | |
MonadError BuiltinError BuiltinResult Source # |
|
Defined in PlutusCore.Builtin.Result throwError :: BuiltinError -> BuiltinResult a Source # catchError :: BuiltinResult a -> (BuiltinError -> BuiltinResult a) -> BuiltinResult a Source # |
throwNotAConstant :: MonadError BuiltinError m => m void Source #
class HasConstant term where Source #
Ensures that term
has a Constant
-like constructor to lift values to and unlift values from.
asConstant :: term -> Either BuiltinError (Some (ValueOf (UniOf term))) Source #
Unwrap from a Constant
-like constructor throwing an UnliftingError
if the provided
term
is not a wrapped Haskell value.
fromConstant :: Some (ValueOf (UniOf term)) -> term Source #
Wrap a Haskell value as a term
.
Instances
HasConstant val => HasConstant (Opaque val rep) Source # | |
Defined in PlutusCore.Builtin.Polymorphism | |
HasConstant (SomeConstant uni rep) Source # | |
Defined in PlutusCore.Builtin.Polymorphism asConstant :: SomeConstant uni rep -> Either BuiltinError (Some (ValueOf (UniOf (SomeConstant uni rep)))) Source # fromConstant :: Some (ValueOf (UniOf (SomeConstant uni rep))) -> SomeConstant uni rep Source # | |
HasConstant (CkValue uni fun) Source # | |
Defined in PlutusCore.Evaluation.Machine.Ck | |
HasConstant (CekValue uni fun ann) Source # | |
HasConstant (Term name uni fun ()) Source # | |
Defined in UntypedPlutusCore.Core.Type | |
HasConstant (Term TyName Name uni fun ()) Source # | |
type HasConstantIn uni term = (UniOf term ~ uni, HasConstant term) Source #
Ensures that term
has a Constant
-like constructor to lift values to and unlift values from
and connects term
and its uni
.
fromValueOf :: forall a term. HasConstant term => UniOf term (Esc a) -> a -> term Source #
Wrap a Haskell value (given its explicit type tag) as a term
.
fromValue :: forall a term. (HasConstant term, UniOf term `HasTermLevel` a) => a -> term Source #
Wrap a Haskell value (provided its type is in the universe) as a term
.