Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype ProductIsData (a :: Type) = ProductIsData a
- newtype EnumIsData (a :: Type) = EnumIsData a
- unProductIsData :: forall (a :: Type). ProductIsData a -> a
- newtype DerivePConstantViaDataList (h :: Type) (p :: S -> Type) = DerivePConstantViaDataList h
- newtype DerivePConstantViaEnum (h :: Type) (p :: S -> Type) = DerivePConstantEnum h
- data PlutusTypeEnumData
- data PlutusTypeDataList
- pmatchEnum :: forall (a :: Type) (b :: S -> Type) (s :: S). (Bounded a, Enum a) => Term s PInteger -> (a -> Term s b) -> Term s b
- pmatchEnumFromData :: forall (a :: Type) (b :: S -> Type) (s :: S). (Bounded a, Enum a) => Term s PData -> (Maybe a -> Term s b) -> Term s b
PlutusTx ToData/FromData derive-wrappers
newtype ProductIsData (a :: Type) Source #
Wrapper for deriving ToData
, FromData
using the List
constructor of Data to represent a Product type.
It is recommended to use PlutusTypeDataList
when deriving
PlutusType
as it provides some basic safety by ensuring
Plutarch types have an Inner type of PDataRecord
.
Uses gProductToBuiltinData
, gproductFromBuiltinData
.
Example
import qualified Generics.SOP as SOP data Foo = Foo Integer [Integer] deriving stock (Generic) deriving anyclass (SOP.Generic) deriving (FromData, ToData) via (ProductIsData Foo) deriving (PConstantDecl) via (DerivePConstantViaDataList Foo PFoo) instance PUnsafeLiftDecl PFoo where type PLifted PFoo = Foo newtype PFoo s = PFoo ( Term s ( PDataRecord '[ "abc" ':= PInteger , "def" ':= PBuiltinList (PAsData PInteger) ] ) ) deriving stock (Generic) deriving anyclass (SOP.Generic) deriving anyclass (PlutusType, PIsData) instance DerivePlutusType PFoo where type DPTStrat _ = PlutusTypeDataList
Since: 3.8.0
Instances
(IsProductType a repr, All FromData repr) => FromData (ProductIsData a) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData fromBuiltinData :: BuiltinData -> Maybe (ProductIsData a) Source # | |
(IsProductType a repr, All ToData repr) => ToData (ProductIsData a) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData toBuiltinData :: ProductIsData a -> BuiltinData Source # | |
(IsProductType a repr, All UnsafeFromData repr) => UnsafeFromData (ProductIsData a) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData |
newtype EnumIsData (a :: Type) Source #
Instances
Enum a => FromData (EnumIsData a) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData fromBuiltinData :: BuiltinData -> Maybe (EnumIsData a) Source # | |
Enum a => ToData (EnumIsData a) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData toBuiltinData :: EnumIsData a -> BuiltinData Source # | |
Enum a => UnsafeFromData (EnumIsData a) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData |
unProductIsData :: forall (a :: Type). ProductIsData a -> a Source #
Since: 3.8.0
Plutarch PIsData/PlutusType derive-wrappers
newtype DerivePConstantViaDataList (h :: Type) (p :: S -> Type) Source #
Variant of PConstantViaData
using the List repr from ProductIsData
Instances
(FromData h, ToData h, PLift p) => PConstantDecl (DerivePConstantViaDataList h p) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData type PConstantRepr (DerivePConstantViaDataList h p) Source # type PConstanted (DerivePConstantViaDataList h p) :: PType Source # | |
type PConstantRepr (DerivePConstantViaDataList h p) Source # | |
Defined in Plutarch.Extra.IsData | |
type PConstanted (DerivePConstantViaDataList h p) Source # | |
Defined in Plutarch.Extra.IsData |
newtype DerivePConstantViaEnum (h :: Type) (p :: S -> Type) Source #
Wrapper for deriving PConstantDecl
using an Integer representation via Enum
.
Since: 1.1.0
Instances
(PLift p, Enum h, DerivePlutusType p, DPTStrat p ~ PlutusTypeEnumData) => PConstantDecl (DerivePConstantViaEnum h p) Source # | Since: 1.1.0 |
Defined in Plutarch.Extra.IsData type PConstantRepr (DerivePConstantViaEnum h p) Source # type PConstanted (DerivePConstantViaEnum h p) :: PType Source # pconstantToRepr :: DerivePConstantViaEnum h p -> PConstantRepr (DerivePConstantViaEnum h p) Source # pconstantFromRepr :: PConstantRepr (DerivePConstantViaEnum h p) -> Maybe (DerivePConstantViaEnum h p) Source # | |
type PConstantRepr (DerivePConstantViaEnum h p) Source # | |
Defined in Plutarch.Extra.IsData | |
type PConstanted (DerivePConstantViaEnum h p) Source # | |
Defined in Plutarch.Extra.IsData |
Plutarch deriving strategy
data PlutusTypeEnumData Source #
Instances
PlutusTypeStrat PlutusTypeEnumData Source # | |
Defined in Plutarch.Extra.IsData type PlutusTypeStratConstraint PlutusTypeEnumData :: PType -> Constraint Source # type DerivedPInner PlutusTypeEnumData a :: PType Source # derivedPCon :: forall a (s :: S). (DerivePlutusType a, DPTStrat a ~ PlutusTypeEnumData) => a s -> Term s (DerivedPInner PlutusTypeEnumData a) Source # derivedPMatch :: forall a (s :: S) (b :: PType). (DerivePlutusType a, DPTStrat a ~ PlutusTypeEnumData) => Term s (DerivedPInner PlutusTypeEnumData a) -> (a s -> Term s b) -> Term s b Source # | |
type PlutusTypeStratConstraint PlutusTypeEnumData Source # | |
Defined in Plutarch.Extra.IsData | |
type DerivedPInner PlutusTypeEnumData a Source # | |
Defined in Plutarch.Extra.IsData |
data PlutusTypeDataList Source #
Since: 3.5.0
Instances
PlutusTypeStrat PlutusTypeDataList Source # | |
Defined in Plutarch.Extra.IsData type PlutusTypeStratConstraint PlutusTypeDataList :: PType -> Constraint Source # type DerivedPInner PlutusTypeDataList a :: PType Source # derivedPCon :: forall a (s :: S). (DerivePlutusType a, DPTStrat a ~ PlutusTypeDataList) => a s -> Term s (DerivedPInner PlutusTypeDataList a) Source # derivedPMatch :: forall a (s :: S) (b :: PType). (DerivePlutusType a, DPTStrat a ~ PlutusTypeDataList) => Term s (DerivedPInner PlutusTypeDataList a) -> (a s -> Term s b) -> Term s b Source # | |
type PlutusTypeStratConstraint PlutusTypeDataList Source # | |
Defined in Plutarch.Extra.IsData | |
type DerivedPInner PlutusTypeDataList a Source # | |
Defined in Plutarch.Extra.IsData |