[Haskell-cafe] Justification for Ord inheriting from Eq?
steve at fenestra.com
Thu Apr 6 17:11:38 EDT 2006
On Thu, 6 Apr 2006 21:31:24 +0100, you wrote:
>I've been wondering for a long time if there is a reason why Ord should
>inherit from Eq and not vice versa, or whether in fact there is any
>justification for making either Ord or Eq inherit from the other one.
Support for the concept of equality/inequality does NOT imply the
existence of an absolute ordering. For example, identical twins can be
considered to be "equal" to each other, and "not equal" to any other
person, while persons who are not half of an identical twin pair are
"not equal" to all other persons. (For simplicity, I've ignored the
existence of identical triplets, quadruplets, etc.) For an example
that's perhaps a bit closer to home, consider modulo arithmetic (or any
other cyclic group). Another example is the definition of NaN
(not-a-number) comparisons in the IEEE floating-point arithmetic
standard: If you have two operands, where at least one of them is a NaN,
then ==, >, <, <= and >= all return False, while /= returns True.
On the other hand, while I suppose it's conceivable to have a situation
where there is an absolute ordering but no equality/inequality, it puts
you in the awkward position of not being able to compare something to
Fenestra Technologies Corp.
More information about the Haskell-Cafe