One thing to consider is that, if you look at the Report specification for derived Ord instances and of the default (compare), you'll find that it explicitly depends on (==). So you don't actually need a "law" here.
Dear Cafe,
I am somewhat surprised that the Haskell Standard (*)
https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1270006.3
does not contain any
notation for (intended) properties of Eq and Ord instances,
and their relation. For Java (standard library),
the API spec uses wording like "consistent with equals"
https://docs.oracle.com/javase/10/docs/api/java/lang/Comparable.html
I am well aware that semantics (transitivity, etc.)
cannot be enforced statically, in either language.
But both standards still speak of "total order".
Do we (Haskell) need something similar to "consistent with equals"?
It depends. E.g., looking at a (random) source in containers
(Data.Map.Internal), it seems that it will always use the result of
compare, never of (==), on keys. That's not obvious from the docs.
I just checked -- I can make a type where (==) = undefined,
but write a proper Ord instance, and use it as key type.
I am asking this because I will be teaching type classes,
with Eq and Ord as examples. I detected the funny situation
that the Java specification looks "more mathematical"
than the corresponding Haskell one. What will the students think ...
- J.W.
(*) The Haskell standard is what you find when you scroll
down, down, down to the very bottom of
https://www.haskell.org/documentation . So, probably not that important...
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
--
brandon s allbery kf8nh sine nomine associates