plutus-tx-1.38.0.0: Libraries for Plutus Tx and its prelude
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusTx.IsData.Class

Synopsis

Documentation

class ToData (a ∷ Type) where Source #

A typeclass for types that can be converted to and from BuiltinData.

Methods

toBuiltinData ∷ a → BuiltinData Source #

Convert a value to BuiltinData.

Instances

Instances details
ToData Void Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinBLS12_381_G1_Element Source #

For the BLS12-381 G1 and G2 types we use the compress functions to convert to a ByteString and then encode that as Data as usual. We have to be more careful going the other way because we decode a Data object to (possibly) get a BuiltinByteString and then uncompress the underlying ByteString to get a group element. However uncompression can fail so we have to check what happens: we don't use bls12_381_G?_uncompress because that invokes error if something goes wrong (but we do use it for unsafeFromData).

Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinBLS12_381_G2_Element Source # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "toBuiltinData is not supported for BuiltinBLS12_381_MlResult") ∷ Constraint) ⇒ ToData BuiltinBLS12_381_MlResult Source #

We do not provide instances of any of these classes for BuiltinBLS12_381_MlResult since there is no serialisation format: we expect that values of that type will only occur as the result of on-chain computations.

Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinData Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData Rational Source # 
Instance details

Defined in PlutusTx.Ratio

ToData Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

ToData Integer Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData () Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData ∷ () → BuiltinData Source #

ToData Bool Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(TypeError ('Text "Int is not supported, use Integer instead") ∷ Constraint) ⇒ ToData Int Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

ToData a ⇒ ToData (Maybe a) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

ToData a ⇒ ToData [a] Source # 
Instance details

Defined in PlutusTx.IsData.Class

Methods

toBuiltinData ∷ [a] → BuiltinData Source #

(ToData a, ToData b) ⇒ ToData (Either a b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(ToData k, ToData v) ⇒ ToData (Map k v) Source #

Hand-written instances to use the underlying Map type in Data, and to be reasonably efficient.

Instance details

Defined in PlutusTx.AssocMap

Methods

toBuiltinDataMap k v → BuiltinData Source #

ToData (Map k a) Source # 
Instance details

Defined in PlutusTx.Data.AssocMap

Methods

toBuiltinDataMap k a → BuiltinData Source #

(ToData a, ToData b) ⇒ ToData (These a b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(ToData a, ToData b) ⇒ ToData (a, b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData ∷ (a, b) → BuiltinData Source #

(ToData a, ToData b, ToData c) ⇒ ToData (a, b, c) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData ∷ (a, b, c) → BuiltinData Source #

(ToData a, ToData b, ToData c, ToData d) ⇒ ToData (a, b, c, d) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

toBuiltinData ∷ (a, b, c, d) → BuiltinData Source #

class FromData (a ∷ Type) where Source #

Methods

fromBuiltinDataBuiltinDataMaybe a Source #

Convert a value from BuiltinData, returning Nothing if this fails.

Instances

Instances details
FromData Void Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinBLS12_381_G1_Element Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinBLS12_381_G2_Element Source # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "fromBuiltinData is not supported for BuiltinBLS12_381_MlResult") ∷ Constraint) ⇒ FromData BuiltinBLS12_381_MlResult Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinData Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData Rational Source # 
Instance details

Defined in PlutusTx.Ratio

FromData Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

FromData Integer Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData () Source # 
Instance details

Defined in PlutusTx.IsData.Instances

FromData Bool Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(TypeError ('Text "Int is not supported, use Integer instead") ∷ Constraint) ⇒ FromData Int Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

FromData a ⇒ FromData (Maybe a) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

FromData a ⇒ FromData [a] Source # 
Instance details

Defined in PlutusTx.IsData.Class

(FromData a, FromData b) ⇒ FromData (Either a b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(FromData k, FromData v) ⇒ FromData (Map k v) Source #

A hand-written transformation from Data to Map. Compared to unsafeFromBuiltinData, it is safe to call when it is unknown if the Data is built with Datas Map constructor. Note that it is, however, unsafe in the sense that it assumes that any map encoded in the Data is well-formed, i.e. fromBuiltinData does not perform any deduplication of keys or of key-value pairs!

Instance details

Defined in PlutusTx.AssocMap

FromData (Map k a) Source # 
Instance details

Defined in PlutusTx.Data.AssocMap

(FromData a, FromData b) ⇒ FromData (These a b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(FromData a, FromData b) ⇒ FromData (a, b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

fromBuiltinDataBuiltinDataMaybe (a, b) Source #

(FromData a, FromData b, FromData c) ⇒ FromData (a, b, c) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

fromBuiltinDataBuiltinDataMaybe (a, b, c) Source #

(FromData a, FromData b, FromData c, FromData d) ⇒ FromData (a, b, c, d) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

fromBuiltinDataBuiltinDataMaybe (a, b, c, d) Source #

class UnsafeFromData (a ∷ Type) where Source #

Methods

unsafeFromBuiltinDataBuiltinData → 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!

This is a simple type without any validation, use with caution.

Instances

Instances details
UnsafeFromData Void Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinBLS12_381_G1_Element Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinBLS12_381_G2_Element Source # 
Instance details

Defined in PlutusTx.IsData.Class

(TypeError ('Text "unsafeFromBuiltinData is not supported for BuiltinBLS12_381_MlResult") ∷ Constraint) ⇒ UnsafeFromData BuiltinBLS12_381_MlResult Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData BuiltinData Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData Rational Source # 
Instance details

Defined in PlutusTx.Ratio

UnsafeFromData Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

UnsafeFromData Integer Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData () Source # 
Instance details

Defined in PlutusTx.IsData.Instances

UnsafeFromData Bool Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(TypeError ('Text "Int is not supported, use Integer instead") ∷ Constraint) ⇒ UnsafeFromData Int Source # 
Instance details

Defined in PlutusTx.IsData.Class

UnsafeFromData (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

UnsafeFromData a ⇒ UnsafeFromData (Maybe a) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

UnsafeFromData a ⇒ UnsafeFromData [a] Source # 
Instance details

Defined in PlutusTx.IsData.Class

(UnsafeFromData a, UnsafeFromData b) ⇒ UnsafeFromData (Either a b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(UnsafeFromData k, UnsafeFromData v) ⇒ UnsafeFromData (Map k v) Source #

A hand-written transformation from Data to Map. It is unsafe because the caller must provide the guarantee that the Data is constructed using the Datas Map constructor. Note that it assumes, like the fromBuiltinData transformation, that the map encoded in the Data is well-formed, i.e. unsafeFromBuiltinData does not perform any deduplication of keys or of key-value pairs!

Instance details

Defined in PlutusTx.AssocMap

UnsafeFromData (Map k a) Source # 
Instance details

Defined in PlutusTx.Data.AssocMap

(UnsafeFromData a, UnsafeFromData b) ⇒ UnsafeFromData (These a b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(UnsafeFromData a, UnsafeFromData b) ⇒ UnsafeFromData (a, b) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

(UnsafeFromData a, UnsafeFromData b, UnsafeFromData c) ⇒ UnsafeFromData (a, b, c) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

unsafeFromBuiltinDataBuiltinData → (a, b, c) Source #

(UnsafeFromData a, UnsafeFromData b, UnsafeFromData c, UnsafeFromData d) ⇒ UnsafeFromData (a, b, c, d) Source # 
Instance details

Defined in PlutusTx.IsData.Instances

Methods

unsafeFromBuiltinDataBuiltinData → (a, b, c, d) Source #

toDataToData a ⇒ a → Data Source #

Convert a value to Data.

fromDataFromData a ⇒ DataMaybe a Source #

Convert a value from Data, returning Nothing if this fails.

unsafeFromDataUnsafeFromData a ⇒ Data → a Source #

Convert a value from Data, throwing if this fails.