Module

Cardano.Plutus.DataSchema

#PSchema

data PSchema :: forall (k :: Type). k -> Typedata PSchema k

A kind (never exists as a term). This is the kind of @PCons@ and @PNil@.

#HasPlutusSchema

class HasPlutusSchema :: Type -> PlutusSchema -> Constraintclass HasPlutusSchema t schema | t -> schema

A class used to associate types with a Plutus Data Schema. The fundeps should guarantee that only one schema can exist for each type. This allows us to make the compiler select the schema associated with a particular type.

#PNil

data PNil :: forall (k :: Type). PSchema kdata PNil

Listlike constructors for the PSchema kind.

Instances

#PCons

data PCons :: forall (k :: Type). Field k -> PSchema k -> PSchema kdata PCons t0 t1

Instances

#ApPCons

type ApPCons :: forall (k :: Type). Field k -> PSchema k -> PSchema ktype ApPCons x xs = PCons x xs

Type synonym which is used to provide syntatic sugar to PCons. You can think of :+ as a type level version of : for PSchema

#Id

data Id :: forall (k :: Type). k -> Typedata Id k

FooB {fooo :: Bool, foo :: Bool} A type level Identity "functor kind". This is mainly used to overload the ':=' type operator.

#I

data I :: forall (k :: Type). k -> Id kdata I t0

Instances

#type (:+)

Operator alias for Cardano.Plutus.DataSchema.ApPCons (right-associative / precedence 0)

#IxK

data IxK :: forall (k :: Type). k -> Typedata IxK k

Indexed kind. A kind representing a type @k@ indexed by a type level natural number @n@.

#MkIxK

data MkIxK :: forall (k :: Type). Nat -> k -> IxK kdata MkIxK t0 t1

A data type of Kind (IxK k n) for some k and n

Instances

#MkIxK_

type MkIxK_ :: forall k1. k1 -> Nat -> IxK k1type MkIxK_ k n = MkIxK n k

Syntactic sugar which allows us to represent MkIxK as a type operator

#type (@@)

Operator alias for Cardano.Plutus.DataSchema.MkIxK_ (right-associative / precedence 9)

#Field

data Field :: forall (k :: Type). k -> Typedata Field k

A kind which is used to represent pairs of Symbols and IxKs. A fancy type level tuple, more or less.

#MkField

data MkField :: forall (k :: Type) (f :: Type -> Type). Symbol -> f k -> Field kdata MkField t0 t1

A data type of Kind (Field k)

Instances

#MkField_

type MkField_ :: forall (f :: Type -> Type) (k :: Type). Symbol -> f k -> Field ktype MkField_ lbl ixty = MkField lbl ixty

Type synonym used to represent MkField as a type operator.

#type (:=)

Operator alias for Cardano.Plutus.DataSchema.MkField_ (right-associative / precedence 8)

#SchemaToRowList

class SchemaToRowList :: forall (k :: Type). PSchema k -> RowList k -> Constraintclass SchemaToRowList schema list | schema -> list

Helper type classes used to convert a PlutusSchema to a RowListI (RowList k). Should not need to be used outside of this module.

Instances

#PlutusSchemaToRowListI

#AllUnique2

class AllUnique2 :: forall (k :: Type). RowListI (RowList k) -> Constraintclass AllUnique2 rList 

A class which ensures that the Nat indices of the RowListI are unique & that the Symbol labels of both the RowListI and RowList in a RowListI (RowList k) all contain unique labels (relative to their "level", i.e., two record arguments of different constructors can have overlapping labels, but constructor names cannot overlap, nor can two labels or indices of the same record)

Instances

#ValidPlutusSchema

class ValidPlutusSchema :: PlutusSchema -> RowListI (RowList Type) -> Constraintclass (PlutusSchemaToRowListI schema list, AllUnique2 list) <= ValidPlutusSchema schema list | schema -> list

The class which validates a Plutus Schema. To make use of genericFromData / genericToData, a type must have an associated Plutus Data schema which satisfies this constraint.

Instances

Re-exports from Cardano.Plutus.DataSchema.Indexed

#RowListI

data RowListI :: forall (k :: Type). k -> Typedata RowListI k

A kind for unordered RowLists which contain a Nat representation of their intended position in a non-lexicographic order. Actual RowLists are automagically ordered lexicographically, Haskell records are not ordered lexicographically, so we need this to encode the structure of Haskell records precisely.

#ConsI

data ConsI :: forall (k :: Type). Symbol -> k -> Nat -> RowListI k -> RowListI kdata ConsI t0 t1 t2 t3

Instances

#AllUniqueLabelsI

class AllUniqueLabelsI :: forall (k :: Type). RowListI k -> Constraintclass AllUniqueLabelsI list 

Uniqueness constraint on the labels of a RowListI which asserts that all labels are unique. Again, this is needed so that the lookup functions perform in the expected manner.

Instances

#GetIndexWithLabel

class GetIndexWithLabel :: forall (k :: Type). Symbol -> RowListI k -> Nat -> Constraintclass (IsSymbol label) <= GetIndexWithLabel label list n | label list -> n

Get the Nat index corresponding to a given symbol index in a RowListI. This is meant to be used primarily in the context of an instance declaration for some other class (see examples in ToData.purs), and is probably not particularly useful outside of those instance contexts.

Instances

#GetLabelIndex

class GetLabelIndex :: forall (k :: Type). Symbol -> RowList k -> Nat -> Constraintclass GetLabelIndex label list result | label list -> result

Get the nat index at a symbol in a RowList (Note: Not a RowListI! Use GetIndexWithLabel for a RowListI)

Instances

#GetLabelWithIndex

class GetLabelWithIndex :: forall (k :: Type). Nat -> RowListI k -> Symbol -> Constraintclass (KnownNat ix, AllUniqueLabelsI list, UniqueIndices list) <= GetLabelWithIndex ix list label | ix list -> label

Given a Nat which appears as an index in the given RowListI, get its corresponding Symbol label

Instances

#GetWithLabel

class GetWithLabel :: forall (k :: Type). Symbol -> RowListI k -> k -> Constraintclass GetWithLabel label rlist result | label rlist -> result

Given a Symbol which appears as a label in the given RowListI, get ahold of the type indexed by that symbol. Note that this does not "return" a value of that type, but the type itself, and is therefore only suitable for type class instance contexts (& other type level computational contexts if any exist)

Instances

#IndexRowList

class IndexRowList :: forall (k :: Type). RowList k -> RowListI k -> Constraintclass IndexRowList list result | list -> result

Helper class for GetLabelIndex. Converts a RowList into a RowListI using its natural order (beginning with Z)

Instances

#IndexRowListWithAcc

class IndexRowListWithAcc :: forall (k :: Type). Nat -> RowList k -> RowListI k -> Constraintclass IndexRowListWithAcc acc list result | acc list -> result

Helper class for IndexRowListWithAcc.

Instances

#UniqueIndices

class UniqueIndices :: forall (k :: Type). RowListI k -> Constraintclass UniqueIndices list 

Uniqueness constraint on the Nat indices of a RowListI which asserts that all indices are unique. This is needed to ensure that the various "lookup" classes return the "values" (types) that we expect.

Instances

Re-exports from Cardano.Plutus.DataSchema.Nat

#Z

data Z :: Natdata Z

Type level natural numbers. We need these for a variety of inductive "operations" (i.e. type classes w/ fundeps)

Instances

#S

data S :: Nat -> Natdata S t0

Instances

#Nat

data Nat

The kind of type level natural number. This is not strictly needed, but improves the legibility of type errors and facilitates more comprehensible type signatures

#KnownNat

class KnownNat :: Nat -> Constraintclass KnownNat n 

PureScript version of the Haskell class defined in GHC.TypeLits. This is the Nat version of IsSymbol, more or less.

Instances

Modules