Module

Cardano.ToData

#ToData

class ToData a  where

Classes

Members

Instances

#ToDataArgs

class ToDataArgs :: Type -> Symbol -> Type -> Constraintclass (IsSymbol constr) <= ToDataArgs t constr a  where

As explained in https://harry.garrood.me/blog/write-your-own-generics/ this is just a neat pattern that flattens a skewed Product of Products

Members

Instances

#ToDataWithSchema

class ToDataWithSchema t a  where

A class which converts a type to its PlutusData representation with the help of a generated or user-defined Plutus Data Schema (see TypeLevel.DataSchema.purs). We cannot express the constraint that the first type argument have an instance of @HasPlutusSchema@ with a superclass, but in practice every instance of this class will have an instance of that class as well.

Members

Instances

#ToDataArgsRL

class ToDataArgsRL :: forall (k :: Type). Type -> Symbol -> RowList k -> Row Type -> Constraintclass (ToDataArgsRLHelper t constr list row) <= ToDataArgsRL t constr list row | t constr list -> row where

A helper typeclass to implement ToDataArgs for records. Adapted from https://github.com/purescript/purescript-quickcheck/blob/v7.1.0/src/Test/QuickCheck/Arbitrary.purs#L247

The Symbol argument represents the name of a constructor. To account for Sum types where multiple variants of the sum have records with the same name, we have to know the name of the constructor (at the type level). See TypeLevel.DataSchema for a more in depth explanation.

Members

Instances

#ToDataArgsRLHelper

class ToDataArgsRLHelper :: forall (k :: Type). Type -> Symbol -> RowList k -> Row Type -> Constraintclass ToDataArgsRLHelper t constr list row | t constr list -> row where

A helper class used to implement ToDataArgsRL. This mainly exists for performance / ergonomic reasons; specifically, it allows us to only sort once (and not have to worry about maintaing the correct order as we go, which reduces the potential for errors)

Members

Instances

#genericToData

genericToData :: forall (t :: Type) (rep :: Type). Generic t rep => ToDataWithSchema t rep => t -> PlutusData

Modules