-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymorphically deriving PLift,PConstant without the headaches #286
Labels
enhancement
New feature or request
Comments
As an example of using data Component a = Component
{cValue :: Plutus.Value,
cDatum :: a
}
data PComponent (a :: PType) (s :: S)
= PComponent (Term s (PDataRecord '["_0" ':= PValue, "_1" ':= a]))
deriving stock (GHC.Generic)
deriving anyclass (SOP.Generic, PIsDataRepr)
deriving
(PMatch, PIsData)
via PIsDataReprInstances (PComponent a)
instance
forall a .
( a ~ (PConstanted (PLifted a))
, PUnsafeLiftDecl a
, Ledger.FromData (Component (PLifted a))
, Ledger.ToData (Component (PLifted a))
) =>
PUnsafeLiftDecl (PComponent a) where
type PLifted (PComponent a) = Component (PLifted a)
deriving via
(DerivePConstantViaData
(Component a)
(PComponent (PConstanted a)))
instance
(a ~ (PLifted (PConstanted a))
, PUnsafeLiftDecl (PConstanted a)
, PConstant a
, Ledger.FromData (Component a)
, Ledger.ToData (Component a)
) =>
PConstant (Component a) |
For |
@peter-mlabs if you want to you can try contributing the PR |
Merged
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DerivePConstantViaNewtype
is pretty painful to use with polymorphic types - the Constraints required for the derived instances are leaky. An example is:One idea to simplify is with Constraint synonyms which provide a shorthand for the constraints:
The text was updated successfully, but these errors were encountered: