-
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
Remove POrd instance of PValue - add PPartialOrd
#528
Conversation
Add `PPartialOrd` instance instead
Plutarch/Bool.hs
Outdated
@@ -89,6 +90,18 @@ class PEq t => POrd t where | |||
infix 4 #<= | |||
infix 4 #< | |||
|
|||
-- | Partial ordering relation. | |||
class PPartialOrd t where | |||
pleq :: Term s t -> Term s t -> Term s PBool |
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.
should these methods be Plutarch level functions instead?
Plutarch/Bool.hs
Outdated
@@ -89,6 +90,18 @@ class PEq t => POrd t where | |||
infix 4 #<= | |||
infix 4 #< | |||
|
|||
-- | Partial ordering relation. | |||
class PPartialOrd t 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.
Should this become a superclass of POrd
? It'd require adding all the instances everywhere else
One possibility is to choose the design Rust chose, but when would you depend on a PPartialOrd constraint rather than POrd? We could move #< etc. to PPartialOrd, make a superclass relation, and then derive PPartialOrd for everything that has POrd, but would you ever use the PPartialOrd instance? Is it confusing that you can use < for some things, but only #< for others?
I feel like Rust's approach might be the best solution, but really, we want PartialOrd too.
|
Wouldn't Rust's approach be suboptimal in UPLC, if we adopt I imagine there won't be much user-written polymorphic code; when writing a contract people tend to know what type they're dealing with. It's only the library writers who will have to decide between |
I also think moving things into |
Moved the |
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.
LGTM, great!
@L-as wait we still needed to add laws? |
@TotallyNotChase Well we can do that in another PR and it's not essential for 1.2 IMO. |
Closes #526