liqwid-plutarch-extra-3.21.1: A collection of Plutarch extras from Liqwid Labs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plutarch.Extra.Record

Synopsis

Documentation

mkRecord :: forall (r :: [PLabeledType]) (s :: S). RecordMorphism s '[] r -> Term s (PDataRecord r) Source #

Turn a constant RecordMorphism into a fully built PDataRecord.

Since: 1.3.0

mkRecordConstr Source #

Arguments

:: forall (r :: [PLabeledType]) (s :: S) (pt :: S -> Type). PlutusType pt 
=> (forall s'. Term s' (PDataRecord r) -> pt s')

The constructor. This is just the Haskell-level constructor for the type. For PMaybeData, this would be PDJust, or PNothing.

-> RecordMorphism s '[] r

The morphism that builds the record.

-> Term s pt 

mkRecord but for known data-types.

This allows you to dynamically construct a record type constructor.

Example:

mkRecordConstr
  PScriptContext
  ( #txInfo .= '(Your PTxInfo)'
      .& #purpose .= '(Your PScriptPurpose)'
  )

Is the same as

pconstant (ScriptContext '(Your TxInfo)' '(Your ScriptPurpose)')

Since: 1.3.0

(.=) infix 7 Source #

Arguments

:: forall (sym :: Symbol) (a :: S -> Type) (as :: [PLabeledType]) (s :: S). FieldName sym

The field name. You can use -XOverloadedLabels to enable the syntax: #hello ~ FieldName "hello"

-> Term s (PAsData a)

The value at that field. This must be PAsData, because the underlying type is Constr Integer [Data].

-> RecordMorphism s as ((sym := a) ': as) 

Cons a labeled type as a RecordMorphism.

Since: 3.1.0

(.&) :: forall (s :: S) (a :: [PLabeledType]) (b :: [PLabeledType]) (c :: [PLabeledType]). RecordMorphism s b c -> RecordMorphism s a b -> RecordMorphism s a c infixr 6 Source #

Compose two RecordMorphisms.

Since: 1.3.0

data RecordMorphism (s :: S) (as :: [PLabeledType]) (bs :: [PLabeledType]) Source #

A morphism from one PDataRecord to another, representing some sort of consing of data.

Since: 1.3.0

Instances

Instances details
Category (RecordMorphism s :: [PLabeledType] -> [PLabeledType] -> TYPE LiftedRep) Source #

Since: 1.3.0

Instance details

Defined in Plutarch.Extra.Record

Methods

id :: forall (a :: k). RecordMorphism s a a Source #

(.) :: forall (b :: k) (c :: k) (a :: k). RecordMorphism s b c -> RecordMorphism s a b -> RecordMorphism s a c Source #

data FieldName (sym :: Symbol) Source #

Like Proxy but local to this module.

Since: 1.3.0

Instances

Instances details
sym ~ sym' => IsLabel sym (FieldName sym) Source #

The use of two different Symbols here allows unification to happen, ensuring FieldName has a fully inferred Symbol.

For example, mkRecord (#foo .= pconstantData (42 :: Integer)) gets the correct type. Namely, Term s (PDataRecord '["foo" ':= PInteger]).

Since: 1.3.0

Instance details

Defined in Plutarch.Extra.Record

Methods

fromLabel :: FieldName sym Source #