Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- module PlutusTx.TH
- type CompiledCode = CompiledCodeIn DefaultUni DefaultFun
- data CompiledCodeIn uni fun a
- getPlc :: ( Closed uni, uni `Everywhere` Flat , Flat fun, uni `Everywhere` PrettyConst , GShow uni, Pretty fun) => CompiledCodeIn uni fun a -> Program NamedDeBruijn uni fun ()
- getPir :: ( Closed uni, uni `Everywhere` Flat , Flat fun) => CompiledCodeIn uni fun a -> Maybe ( Program TyName Name uni fun ())
- applyCode :: ( Closed uni, uni `Everywhere` Flat , Flat fun, uni `Everywhere` PrettyConst , GShow uni, Pretty fun) => CompiledCodeIn uni fun (a -> b) -> CompiledCodeIn uni fun a -> CompiledCodeIn uni fun b
- data BuiltinData
- data Data
-
class
ToData
(a ::
Type
)
where
- toBuiltinData :: a -> BuiltinData
-
class
FromData
(a ::
Type
)
where
- fromBuiltinData :: BuiltinData -> Maybe a
-
class
UnsafeFromData
(a ::
Type
)
where
- unsafeFromBuiltinData :: BuiltinData -> a
- toData :: ToData a => a -> Data
- fromData :: FromData a => Data -> Maybe a
- builtinDataToData :: BuiltinData -> Data
- dataToBuiltinData :: Data -> BuiltinData
- unstableMakeIsData :: Name -> Q [ Dec ]
- makeIsDataIndexed :: Name -> [( Name , Int )] -> Q [ Dec ]
- class Lift uni a
- class Typeable uni (a :: k)
- makeLift :: Name -> Q [ Dec ]
- safeLiftCode :: ( Lift uni a, AsTypeError e ( Term TyName Name uni fun ()) uni fun ( Provenance ()), GEq uni, AsTypeErrorExt e uni ( Provenance ()), AsFreeVariableError e, AsError e uni fun ( Provenance ()), MonadError e m, MonadQuote m, Typecheckable uni fun, PrettyPrintable uni fun) => a -> m ( CompiledCodeIn uni fun a)
- liftCode :: ( Lift uni a, Throwable uni fun, Typecheckable uni fun) => a -> CompiledCodeIn uni fun a
Documentation
module PlutusTx.TH
type CompiledCode = CompiledCodeIn DefaultUni DefaultFun Source #
CompiledCodeIn
instantiated with default built-in types and functions.
data CompiledCodeIn uni fun a Source #
A compiled Plutus Tx program. The last type parameter indicates the type of the Haskell expression that was compiled, and hence the type of the compiled code.
Note: the compiled PLC program does *not* have normalized types, if you want to put it on the chain you must normalize the types first.
Instances
( Closed uni, Everywhere uni Flat , Flat fun, Everywhere uni PrettyConst , GShow uni, Pretty fun) => Flat ( CompiledCodeIn uni fun a) Source # | |
Defined in PlutusTx.Code |
getPlc :: ( Closed uni, uni `Everywhere` Flat , Flat fun, uni `Everywhere` PrettyConst , GShow uni, Pretty fun) => CompiledCodeIn uni fun a -> Program NamedDeBruijn uni fun () Source #
Get the actual Plutus Core program out of a
CompiledCodeIn
.
getPir :: ( Closed uni, uni `Everywhere` Flat , Flat fun) => CompiledCodeIn uni fun a -> Maybe ( Program TyName Name uni fun ()) Source #
Get the Plutus IR program, if there is one, out of a
CompiledCodeIn
.
applyCode :: ( Closed uni, uni `Everywhere` Flat , Flat fun, uni `Everywhere` PrettyConst , GShow uni, Pretty fun) => CompiledCodeIn uni fun (a -> b) -> CompiledCodeIn uni fun a -> CompiledCodeIn uni fun b Source #
Apply a compiled function to a compiled argument.
data BuiltinData Source #
A type corresponding to the Plutus Core builtin equivalent of
Data
.
The point of this type is to be an opaque equivalent of
Data
, so as to
ensure that it is only used in ways that the compiler can handle.
As such, you should use this type in your on-chain code, and in any data structures that you want to be representable on-chain.
For off-chain usage, there are conversion functions
builtinDataToData
and
dataToBuiltinData
, but note that these will not work on-chain.
Instances
A generic "data" type.
The main constructor
Constr
represents a datatype value in sum-of-products
form:
Constr i args
represents a use of the
i
th constructor along with its arguments.
The other constructors are various primitives.
Instances
class ToData (a :: Type ) where Source #
A typeclass for types that can be converted to and from
BuiltinData
.
toBuiltinData :: a -> BuiltinData Source #
Convert a value to
BuiltinData
.
Instances
class FromData (a :: Type ) where Source #
fromBuiltinData :: BuiltinData -> Maybe a Source #
Convert a value from
BuiltinData
, returning
Nothing
if this fails.
Instances
class UnsafeFromData (a :: Type ) where Source #
unsafeFromBuiltinData :: BuiltinData -> a Source #
Convert a value from
BuiltinData
, calling
error
if this fails.
This is typically much faster than
fromBuiltinData
.
When implementing this function, make sure to call
unsafeFromBuiltinData
rather than
fromBuiltinData
when converting substructures!
Instances
builtinDataToData :: BuiltinData -> Data Source #
Convert a
BuiltinData
into a
Data
. Only works off-chain.
dataToBuiltinData :: Data -> BuiltinData Source #
Convert a
Data
into a
BuiltinData
. Only works off-chain.
unstableMakeIsData :: Name -> Q [ Dec ] Source #
Generate a
FromData
and a
ToData
instance for a type. This may not be stable in the face of constructor additions,
renamings, etc. Use
makeIsDataIndexed
if you need stability.
Class for types which can be lifted into Plutus IR. Instances should be derived, do not write your own instance!
Instances
class Typeable uni (a :: k) Source #
Class for types which have a corresponding Plutus IR type. Instances should always be derived, do not write your own instance!
Instances
safeLiftCode :: ( Lift uni a, AsTypeError e ( Term TyName Name uni fun ()) uni fun ( Provenance ()), GEq uni, AsTypeErrorExt e uni ( Provenance ()), AsFreeVariableError e, AsError e uni fun ( Provenance ()), MonadError e m, MonadQuote m, Typecheckable uni fun, PrettyPrintable uni fun) => a -> m ( CompiledCodeIn uni fun a) Source #
liftCode :: ( Lift uni a, Throwable uni fun, Typecheckable uni fun) => a -> CompiledCodeIn uni fun a Source #
Get a Plutus Core program corresponding to the given value as a
CompiledCodeIn
, throwing any errors that occur as exceptions and ignoring fresh names.