Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cjay
Copy link
Collaborator

@cjay cjay commented Sep 8, 2022

No description provided.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not derive this

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

Copy link
Collaborator Author

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)
Copy link
Member

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

@L-as
Copy link
Member

L-as commented Sep 22, 2022

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants