Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- newtype PDataSum defs s = PDataSum (NS (Compose (Term s) PDataRecord) defs)
- punDataSum :: Term s (PDataSum '[def] :--> PDataRecord def)
- ptryIndexDataSum :: KnownNat n => Proxy n -> Term s (PDataSum (def ': defs) :--> PDataRecord (IndexList n (def ': defs)))
- pdcons :: forall label a l s. Term s (PAsData a :--> (PDataRecord l :--> PDataRecord ((label ':= a) ': l)))
- pdnil :: Term s (PDataRecord '[])
- data DataReprHandlers (out :: S -> Type) (defs :: [[PLabeledType]]) (s :: S) where
- 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
- 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
- data PLabeledType = Symbol := (S -> Type)
- type family PLabelIndex (name :: Symbol) (as :: [PLabeledType]) :: Nat where ...
- type family PUnLabel (a :: PLabeledType) :: S -> Type where ...
- type family PLookupLabel name as where ...
- pindexDataRecord :: KnownNat n => Proxy n -> Term s (PDataRecord as) -> Term s (PAsData (PUnLabel (IndexList n as)))
- pdropDataRecord :: KnownNat n => Proxy n -> Term s (PDataRecord xs) -> Term s (PDataRecord (Drop n xs))
- newtype DualReprHandler s out def = DualRepr (Term s (PDataRecord def) -> Term s (PDataRecord def) -> Term s out)
- data PlutusTypeData
Documentation
newtype PDataSum defs s Source #
A sum of PDataRecord
s. The underlying representation is the Constr
constructor,
where the integer is the index of the variant and the list is the record.
PDataSum (NS (Compose (Term s) PDataRecord) defs) |
Instances
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
pdnil :: Term s (PDataRecord '[]) Source #
An empty PDataRecord
.
data DataReprHandlers (out :: S -> Type) (defs :: [[PLabeledType]]) (s :: S) where Source #
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`.
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
data PLabeledType Source #
Instances
type family PLabelIndex (name :: Symbol) (as :: [PLabeledType]) :: Nat where ... Source #
PLabelIndex name ((name ':= _) ': _) = 0 | |
PLabelIndex name (_ ': as) = PLabelIndex name as + 1 |
type family PLookupLabel name as where ... Source #
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 #
DualRepr (Term s (PDataRecord def) -> Term s (PDataRecord def) -> Term s out) |
data PlutusTypeData Source #
Instances
PlutusTypeStrat PlutusTypeData Source # | |
Defined in Plutarch.DataRepr.Internal type PlutusTypeStratConstraint PlutusTypeData :: PType -> Constraint Source # type DerivedPInner PlutusTypeData a :: PType Source # derivedPCon :: forall a (s :: S). (DerivePlutusType a, DPTStrat a ~ PlutusTypeData) => a s -> Term s (DerivedPInner PlutusTypeData a) Source # derivedPMatch :: forall a (s :: S) (b :: PType). (DerivePlutusType a, DPTStrat a ~ PlutusTypeData) => Term s (DerivedPInner PlutusTypeData a) -> (a s -> Term s b) -> Term s b Source # | |
type PlutusTypeStratConstraint PlutusTypeData Source # | |
Defined in Plutarch.DataRepr.Internal | |
type DerivedPInner PlutusTypeData a Source # | |
Defined in Plutarch.DataRepr.Internal |