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 encode :: CompiledCodeIn uni fun a -> Encoding decode :: Get (CompiledCodeIn uni fun a) size :: CompiledCodeIn uni fun a -> NumBits -> NumBits |
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
Instances
Eq Data | |
Data Data | |
Defined in PlutusCore.Data gfoldl :: (forall d b. Data0 d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Data -> c Data Source # gunfold :: (forall b r. Data0 b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Data Source # toConstr :: Data -> Constr Source # dataTypeOf :: Data -> DataType Source # dataCast1 :: Typeable t => (forall d. Data0 d => c (t d)) -> Maybe (c Data) Source # dataCast2 :: Typeable t => (forall d e. (Data0 d, Data0 e) => c (t d e)) -> Maybe (c Data) Source # gmapT :: (forall b. Data0 b => b -> b) -> Data -> Data Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data0 d => d -> r') -> Data -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data0 d => d -> r') -> Data -> r Source # gmapQ :: (forall d. Data0 d => d -> u) -> Data -> [u] Source # gmapQi :: Int -> (forall d. Data0 d => d -> u) -> Data -> u Source # gmapM :: Monad m => (forall d. Data0 d => d -> m d) -> Data -> m Data Source # gmapMp :: MonadPlus m => (forall d. Data0 d => d -> m d) -> Data -> m Data Source # gmapMo :: MonadPlus m => (forall d. Data0 d => d -> m d) -> Data -> m Data Source # | |
Ord Data | |
Show Data | |
Generic Data | |
NFData Data | |
Defined in PlutusCore.Data | |
Serialise Data | |
Defined in PlutusCore.Data encodeList :: [Data] -> Encoding decodeList :: Decoder s [Data] | |
Pretty Data | |
Defined in PlutusCore.Data prettyList :: [Data] -> Doc ann | |
ExMemoryUsage Data | |
Defined in PlutusCore.Evaluation.Machine.ExMemory memoryUsage :: Data -> ExMemory | |
PrettyBy ConstConfig Data | |
Defined in PlutusCore.Pretty.PrettyConst prettyBy :: ConstConfig -> Data -> Doc ann prettyListBy :: ConstConfig -> [Data] -> Doc ann | |
Lift DefaultUni Data Source # | |
HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Data | |
Defined in PlutusCore.Default.Universe | |
HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Data | |
Defined in PlutusCore.Default.Universe | |
Contains DefaultUni Data | |
Defined in PlutusCore.Default.Universe | |
KnownBuiltinTypeAst DefaultUni Data => KnownTypeAst DefaultUni Data | |
Defined in PlutusCore.Default.Universe | |
Typeable DefaultUni Data Source # | |
type Rep Data | |
Defined in PlutusCore.Data type Rep Data = D1 ('MetaData "Data" "PlutusCore.Data" "plutus-core-1.0.0.1-6wMiyL0yerXJu56t8zBoKx" 'False) ((C1 ('MetaCons "Constr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Data])) :+: C1 ('MetaCons "Map" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Data, Data)]))) :+: (C1 ('MetaCons "List" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Data])) :+: (C1 ('MetaCons "I" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)) :+: C1 ('MetaCons "B" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))))) | |
type ToBinds Data | |
Defined in PlutusCore.Default.Universe | |
type ToHoles Data | |
Defined in PlutusCore.Default.Universe |
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
Includes uni Text => Lift uni BuiltinString Source # | |
Defined in PlutusTx.Lift.Instances lift :: BuiltinString -> RTCompile uni fun (Term TyName Name uni fun ()) Source # | |
Includes uni ByteString => Lift uni BuiltinByteString Source # | |
Defined in PlutusTx.Lift.Instances lift :: BuiltinByteString -> RTCompile uni fun (Term TyName Name uni fun ()) Source # | |
Includes uni Data => Lift uni BuiltinData Source # | |
Defined in PlutusTx.Lift.Instances lift :: BuiltinData -> RTCompile uni fun (Term TyName Name uni fun ()) Source # | |
Includes uni ByteString => Lift uni ByteString Source # | |
Defined in PlutusTx.Lift.Instances | |
Includes uni Integer => Lift uni Integer Source # | |
(TypeError ('Text "Int is not supported, use Integer instead") :: Constraint) => Lift uni Int Source # | |
Lift DefaultUni Bool Source # | |
Lift DefaultUni () Source # | |
Defined in PlutusTx.Lift.Instances | |
Lift DefaultUni Data Source # | |
Lift DefaultUni Rational Source # | |
Lift DefaultUni Sqrt Source # | |
(FromBuiltin arep a, Includes uni [a]) => Lift uni (BuiltinList arep) Source # | |
Defined in PlutusTx.Lift.Instances lift :: BuiltinList arep -> RTCompile uni fun (Term TyName Name uni fun ()) Source # | |
(Typeable DefaultUni a, Lift DefaultUni a) => Lift DefaultUni [a] Source # | |
Defined in PlutusTx.Lift.Instances | |
(Typeable DefaultUni a, Lift DefaultUni a) => Lift DefaultUni (Maybe a) Source # | |
(Typeable DefaultUni a, Typeable DefaultUni b, Lift DefaultUni a, Lift DefaultUni b) => Lift DefaultUni (Either a b) Source # | |
(Typeable DefaultUni a, Typeable DefaultUni b, Lift DefaultUni a, Lift DefaultUni b) => Lift DefaultUni (a, b) Source # | |
Defined in PlutusTx.Lift.Instances | |
Lift DefaultUni [(k, v)] => Lift DefaultUni (Map k v) Source # | |
(Typeable DefaultUni a, Typeable DefaultUni b, Typeable DefaultUni c, Lift DefaultUni a, Lift DefaultUni b, Lift DefaultUni c) => Lift DefaultUni (a, b, c) Source # | |
Defined in PlutusTx.Lift.Instances | |
(Typeable DefaultUni a, Typeable DefaultUni b, Typeable DefaultUni c, Typeable DefaultUni d, Lift DefaultUni a, Lift DefaultUni b, Lift DefaultUni c, Lift DefaultUni d) => Lift DefaultUni (a, b, c, d) Source # | |
Defined in PlutusTx.Lift.Instances | |
(Typeable DefaultUni a, Typeable DefaultUni b, Typeable DefaultUni c, Typeable DefaultUni d, Typeable DefaultUni e, Lift DefaultUni a, Lift DefaultUni b, Lift DefaultUni c, Lift DefaultUni d, Lift DefaultUni e) => Lift DefaultUni (a, b, c, d, e) Source # | |
Defined in PlutusTx.Lift.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.