plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.DataRepr.Internal

Synopsis

Documentation

newtype PDataSum defs s Source #

A sum of PDataRecords. The underlying representation is the Constr constructor, where the integer is the index of the variant and the list is the record.

Constructors

PDataSum (NS (Compose (Term s) PDataRecord) defs) 

Instances

Instances details
PTryFrom PData (PDataSum ys) => PTryFrom PData (PAsData (PDataSum ys)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess PData (PAsData (PDataSum ys)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PDataSum ys)), Reduce (PTryFromExcess PData (PAsData (PDataSum ys)) s)) -> Term s r) -> Term s r Source #

SumValidation 0 ys => PTryFrom PData (PDataSum ys) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess PData (PDataSum ys) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PDataSum ys), Reduce (PTryFromExcess PData (PDataSum ys) s)) -> Term s r) -> Term s r Source #

PDataFields (PDataSum '[as]) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.Field

Associated Types

type PFields (PDataSum '[as]) :: [PLabeledType] Source #

Methods

ptoFields :: forall (s :: S). Term s (PDataSum '[as]) -> Term s (PDataRecord (PFields (PDataSum '[as]))) Source #

PEq (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#==) :: forall (s :: S). Term s (PDataSum defs) -> Term s (PDataSum defs) -> Term s PBool Source #

PIsData (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData (PDataSum defs)) -> Term s (PDataSum defs) Source #

pdataImpl :: forall (s :: S). Term s (PDataSum defs) -> Term s PData Source #

All (Compose POrd PDataRecord) defs => POrd (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataSum defs) -> Term s (PDataSum defs) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataSum defs) -> Term s (PDataSum defs) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataSum defs) -> Term s (PDataSum defs) -> Term s (PDataSum defs) Source #

pmin :: forall (s :: S). Term s (PDataSum defs) -> Term s (PDataSum defs) -> Term s (PDataSum defs) Source #

SListI defs => PlutusType (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PInner (PDataSum defs) :: PType Source #

type PCovariant' (PDataSum defs) Source #

type PContravariant' (PDataSum defs) Source #

type PVariant' (PDataSum defs) Source #

Methods

pcon' :: forall (s :: S). PDataSum defs s -> Term s (PInner (PDataSum defs)) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner (PDataSum defs)) -> (PDataSum defs s -> Term s b) -> Term s b Source #

(All (Top :: [PLabeledType] -> Constraint) defs, All (Compose PShow PDataRecord) defs) => PShow (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pshow' :: forall (s :: S). Bool -> Term s (PDataSum defs) -> Term s PString Source #

type PTryFromExcess PData (PAsData (PDataSum ys)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess PData (PDataSum ys) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess PData (PDataSum ys) = Const () :: S -> Type
type PFields (PDataSum '[as]) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.Field

type PFields (PDataSum '[as]) = as
type PContravariant' (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PCovariant' (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PCovariant' (PDataSum defs) = All2 PCovariant'' (PCode (PDataSum defs))
type PInner (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PInner (PDataSum defs) = PData
type PVariant' (PDataSum defs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PVariant' (PDataSum defs) = All2 PVariant'' (PCode (PDataSum defs))

punDataSum :: Term s (PDataSum '[def] :--> PDataRecord def) Source #

If there is only a single variant, then we can safely extract it.

ptryIndexDataSum :: KnownNat n => Proxy n -> Term s (PDataSum (def ': defs) :--> PDataRecord (IndexList n (def ': defs))) Source #

Try getting the nth variant. Errs if it's another variant.

pdcons :: forall label a l s. Term s (PAsData a :--> (PDataRecord l :--> PDataRecord ((label ':= a) ': l))) Source #

Cons a field to a data record.

You can specify the label to associate with the field using type applications-

foo :: Term s (PDataRecord '[ "fooField" ':= PByteString ])
foo = pdcons @"fooField" # pdata (phexByteStr "ab") # pdnil

data DataReprHandlers (out :: S -> Type) (defs :: [[PLabeledType]]) (s :: S) where Source #

Constructors

DRHNil :: DataReprHandlers out '[] s 
DRHCons :: (Term s (PDataRecord def) -> Term s out) -> DataReprHandlers out defs s -> DataReprHandlers out (def ': defs) s 

data PDataRecord (as :: [PLabeledType]) (s :: S) where Source #

A "record" of `exists a. PAsData a`. The underlying representation is `PBuiltinList PData`.

Constructors

PDCons :: forall name_x x xs s. PUnLabel name_x ~ x => Term s (PAsData x) -> Term s (PDataRecord xs) -> PDataRecord (name_x ': xs) s 
PDNil :: PDataRecord '[] s 

Instances

Instances details
(PTryFrom (PBuiltinList PData) (PDataRecord as), PTryFromExcess (PBuiltinList PData) (PDataRecord as) ~ HRecP ase) => PTryFrom PData (PAsData (PDataRecord as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess PData (PAsData (PDataRecord as)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PDataRecord as)), Reduce (PTryFromExcess PData (PAsData (PDataRecord as)) s)) -> Term s r) -> Term s r Source #

PDataFields (PDataRecord as) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.Field

Associated Types

type PFields (PDataRecord as) :: [PLabeledType] Source #

Methods

ptoFields :: forall (s :: S). Term s (PDataRecord as) -> Term s (PDataRecord (PFields (PDataRecord as))) Source #

PEq (PDataRecord xs) Source #

This uses data equality. PEq instances of elements don't make any difference.

Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#==) :: forall (s :: S). Term s (PDataRecord xs) -> Term s (PDataRecord xs) -> Term s PBool Source #

PIsData (PDataRecord xs) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData (PDataRecord xs)) -> Term s (PDataRecord xs) Source #

pdataImpl :: forall (s :: S). Term s (PDataRecord xs) -> Term s PData Source #

(SListI xs, POrd x, PIsData x, POrd (PDataRecord (x' ': xs))) => POrd (PDataRecord ((label ':= x) ': (x' ': xs))) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) Source #

pmin :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) Source #

(POrd x, PIsData x) => POrd (PDataRecord '[label ':= x]) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) Source #

pmin :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) Source #

POrd (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) Source #

pmin :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) Source #

SListI l => PlutusType (PDataRecord l) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pcon' :: forall (s :: S). PDataRecord l s -> Term s (PInner (PDataRecord l)) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner (PDataRecord l)) -> (PDataRecord l s -> Term s b) -> Term s b Source #

(All (Top :: PLabeledType -> Constraint) xs, KnownSymbol label, PIsData x, PShow x, PShow (PDataRecordShowHelper xs)) => PShow (PDataRecord ((label ':= x) ': xs)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pshow' :: forall (s :: S). Bool -> Term s (PDataRecord ((label ':= x) ': xs)) -> Term s PString Source #

PShow (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pshow' :: forall (s :: S). Bool -> Term s (PDataRecord '[]) -> Term s PString Source #

(Helper2 (PSubtype' PData pty) pty, PTryFrom (PBuiltinList PData) (PDataRecord as), PTryFromExcess (PBuiltinList PData) (PDataRecord as) ~ HRecP ase) => PTryFrom (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s (PBuiltinList PData) -> ((Term s (PDataRecord ((name ':= pty) ': as)), Reduce (PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) s)) -> Term s r) -> Term s r Source #

PTryFrom (PBuiltinList PData) (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess (PBuiltinList PData) (PDataRecord '[]) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s (PBuiltinList PData) -> ((Term s (PDataRecord '[]), Reduce (PTryFromExcess (PBuiltinList PData) (PDataRecord '[]) s)) -> Term s r) -> Term s r Source #

type PTryFromExcess PData (PAsData (PDataRecord as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PFields (PDataRecord as) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.Field

type PFields (PDataRecord as) = as
type PContravariant' (PDataRecord l) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PCovariant' (PDataRecord l) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PInner (PDataRecord l) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PVariant' (PDataRecord l) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as))
type PTryFromExcess (PBuiltinList PData) (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

data PLabeledType Source #

Constructors

Symbol := (S -> Type) 

Instances

Instances details
PDataFields (PDataSum '[as]) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.Field

Associated Types

type PFields (PDataSum '[as]) :: [PLabeledType] Source #

Methods

ptoFields :: forall (s :: S). Term s (PDataSum '[as]) -> Term s (PDataRecord (PFields (PDataSum '[as]))) Source #

(SListI xs, POrd x, PIsData x, POrd (PDataRecord (x' ': xs))) => POrd (PDataRecord ((label ':= x) ': (x' ': xs))) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) Source #

pmin :: forall (s :: S). Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) -> Term s (PDataRecord ((label ':= x) ': (x' ': xs))) Source #

(POrd x, PIsData x) => POrd (PDataRecord '[label ':= x]) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) Source #

pmin :: forall (s :: S). Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) -> Term s (PDataRecord '[label ':= x]) Source #

POrd (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

(#<=) :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s PBool Source #

(#<) :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s PBool Source #

pmax :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) Source #

pmin :: forall (s :: S). Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) -> Term s (PDataRecord '[]) Source #

(All (Top :: PLabeledType -> Constraint) xs, KnownSymbol label, PIsData x, PShow x, PShow (PDataRecordShowHelper xs)) => PShow (PDataRecord ((label ':= x) ': xs)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pshow' :: forall (s :: S). Bool -> Term s (PDataRecord ((label ':= x) ': xs)) -> Term s PString Source #

PShow (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Methods

pshow' :: forall (s :: S). Bool -> Term s (PDataRecord '[]) -> Term s PString Source #

(Helper2 (PSubtype' PData pty) pty, PTryFrom (PBuiltinList PData) (PDataRecord as), PTryFromExcess (PBuiltinList PData) (PDataRecord as) ~ HRecP ase) => PTryFrom (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s (PBuiltinList PData) -> ((Term s (PDataRecord ((name ':= pty) ': as)), Reduce (PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) s)) -> Term s r) -> Term s r Source #

PTryFrom (PBuiltinList PData) (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess (PBuiltinList PData) (PDataRecord '[]) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s (PBuiltinList PData) -> ((Term s (PDataRecord '[]), Reduce (PTryFromExcess (PBuiltinList PData) (PDataRecord '[]) s)) -> Term s r) -> Term s r Source #

type PFields (PDataSum '[as]) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.Field

type PFields (PDataSum '[as]) = as
type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as))
type PTryFromExcess (PBuiltinList PData) (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type family PLabelIndex (name :: Symbol) (as :: [PLabeledType]) :: Nat where ... Source #

Equations

PLabelIndex name ((name ':= _) ': _) = 0 
PLabelIndex name (_ ': as) = PLabelIndex name as + 1 

type family PUnLabel (a :: PLabeledType) :: S -> Type where ... Source #

Equations

PUnLabel (_ ':= a) = a 

type family PLookupLabel name as where ... Source #

Equations

PLookupLabel name ((name ':= a) ': _) = a 
PLookupLabel name (_ ': as) = PLookupLabel name as 

pindexDataRecord :: KnownNat n => Proxy n -> Term s (PDataRecord as) -> Term s (PAsData (PUnLabel (IndexList n as))) Source #

Safely index a PDataRecord.

pdropDataRecord :: KnownNat n => Proxy n -> Term s (PDataRecord xs) -> Term s (PDataRecord (Drop n xs)) Source #

Safely drop the first n items of a PDataRecord.

newtype DualReprHandler s out def Source #

Constructors

DualRepr (Term s (PDataRecord def) -> Term s (PDataRecord def) -> Term s out)