-
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
PPair instances: PPartialOrd and POrd #572
base: master
Are you sure you want to change the base?
Conversation
@@ -18,3 +18,24 @@ data PPair (a :: PType) (b :: PType) (s :: S) | |||
deriving anyclass (PlutusType, PEq, PShow) | |||
|
|||
instance DerivePlutusType (PPair a b) where type DPTStrat _ = PlutusTypeScott | |||
|
|||
instance (PPartialOrd a, PPartialOrd b) => PPartialOrd (PPair a b) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not derive this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find infrastructure for deriving that. Is there any?
Sorry, I haven't really had time to learn all possibilities of deriving-via yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can derive all classes that have a default for every method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default needs an POrd
instance for PInner
of the type, which in the case of PPair
is PScottEncoded ...
. That one doesn't have a POrd
instance. Are you sure this should be possible somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an issue. Look at the default methods. You can change the constraint to PPartialOrd, but what about deriving POrd? You can add the constraint as a superclass, but perhaps adding a dummy method with a POrd constraint on PInner works best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What mechanism should cause the lexical ordering behavior that you see in my manual implementation? I don't see how changing constraints would help with that. I suppose a better default implementation would have to use generics.
(a2 #< b2) | ||
(a1 #< b1) | ||
|
||
instance (POrd a, POrd b) => POrd (PPair a b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just add this to deriving anyclass
bump |
No description provided.