-
Notifications
You must be signed in to change notification settings - Fork 87
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
Support PartialEq
and PartialOrd
#285
Comments
PartialEq
and PartialOrd`PartialEq
and PartialOrd
It was discussed once long ago, when we considered adding lattices, but the consensus then was it's not common enough to warrant existing in Prelude. I'd still agree with that. How does |
Basically.
Where was that discussed? |
In the thread on lattices, search for |
I’m actually starting to come around to this. In that thread I mainly argued that if we are only going to provide one class for ordering in Prelude then it should be total rather than partial, but if we are considering providing both a partial and a total ordering class then I think that’s a slightly separate discussion. I also overlooked the fact that Number is not a well-behaved Ord there, which is quite an important detail. It feels wrong to me that inserting a NaN into a Map can totally break it, although to be fair I haven’t ever heard of this happening in practice. It’s worth noting that it’s not just Number this would apply to, but also any type which contains a Number. What’s nice about this approach is that while the ordering operators still work on Number, you can also capture trichotomy in the types where you need it by using Your suggested definitions look good to me but I have a couple of notes about the descriptions. Firstly, we want the transitivity law for PartialEq to say “if A equals B and B equals C then A equals C,” which is not quite the same as what you have there. Secondly, I don’t think we would want to describe PartialOrd as a preorder anywhere because a preorder requires reflexivity - |
Oh also, if we do this, I think we should consider having |
Oh, I think we could describe PartialOrd as a strict preorder: https://en.m.wikipedia.org/wiki/Preorder#Strict_preorder |
On the other hand, if you have an A relevant quote from https://michaelfairley.com/blog/i-made-a-game-in-rust/ -
|
Yeah... that would get really old really fast... |
For what it's worth, in my own code I'm moving toward a type This seems like part of a broader, and difficult, problem with Purescript and floating point arithmetic. We get used to all the (substantial) advantages of law-abiding typeclass instances but floating point numbers are never fully law abiding. Not It seems like there are three options:
I'm not sure I have a strong opinion on which path to take but I hope that we take one consistent path (one of the above or something I haven't thought of) rather than mix-and-match. |
See Rust for example:
The text was updated successfully, but these errors were encountered: