Closed bladyjoker closed 10 months ago
This is going to be a tricky one!
Will write down some of my thoughts.
Given a Foo .lbf module:
module Foo
import Plutus
sum FooSum a b = Bar a (Maybe Address) | Baz b (Maybe AssetClass)
derive Eq (FooSum a b)
derive Json (FooSum a b)
derive PlutusData (FooSum a b)
prod FooProd a b = a (Maybe Address) b (Maybe AssetClass)
derive Eq (FooProd a b)
derive Json (FooProd a b)
derive PlutusData (FooProd a b)
prod FooRec a b = {
bar : a (Maybe Address),
baz: b (Maybe AssetClass)
}
derive Eq (FooRec a b)
derive Json (FooRec a b)
derive PlutusData (FooRec a b)
How do we map type definitions and implementations.
module LambdaBuffers.Plutarch.Foo where
data FooSum (a :: PType) (b :: PType) (s :: S) = FooSum'Bar (Term s a) (Term s (PMaybe PAddress))
| FooSum'Baz (Term s b) (Term s (PMaybe PAssetClass))
data FooProd (a :: PType) (b :: PType) (s :: S) = FooProd (Term s a) (Term s (PMaybe PAddress)) (Term s b) (Term s (PMaybe PAssetClass))
data FooRec (a :: PType) (b :: PType) (s :: S) = FooRec {
bar :: (Term s a) (Term s (PMaybe PAddress)),
baz :: (Term s b) (Term s (PMaybe PAssetClass))
}
PDataRecord
or is native product good enough?bar
and baz
field accessors, I guess they are useless, and I must implement some of the Field tcs?module LambdaBuffers.Plutarch.Foo where
instance Plutarch.PlutusType FooSum a b where
pcon = ...
pmatch = ...
instance Plutarch.PlutusType FooProd a b where
pcon = ...
pmatch = ...
instance Plutarch.PlutusType FooRec a b where
pcon = ...
pmatch = ...
instance Plutarch.Eq FooSum a b where
(#==) = plam (\l r -> )
instance Plutarch.Eq FooProd a b where
(#==) = plam (\l r -> )
instance Plutarch.Eq FooRec a b where
(#==) = plam (\l r -> )
[x,y]
and [y,x]
Data representations could be considered valid. I think it needs to be stressed out that PTypes have a canonical and unique value representations.I need a bit more clairification on PlutusType and PIsData relationship...
I'm implementing my pcon'
for my type, and I have to call pdata
on its constituents? This is suprising to me:
Why not further call pcon'
on constituent types?
pcon
d values, ie. constructed values, and now you need access to their Data
form (fundamentally it's already in this form, we just have to massage the types with pdata
)Is default PIsData
implementation doing the above in some way?
pto
which gives you the PData
of your PType (that's what PInner is for).Why would PIsData
implementations, pfromDataImpl and pdataImpl, ever be anything but 'take the underlying PData and pass that along'
I might be forgetting that we have ScottEncoded variants on everything so perhaps that is why?
What's the deal with PTryFrom?
PData
into my Term s Smtn
, is PTryFrom also doing pmatch
in the background (as the default impl)?PEq is interesting
TODO: