[Haskell-cafe] ordNub

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Thu Jan 1 14:04:37 UTC 2015


On Thu, Jan 01, 2015 at 08:58:35AM -0500, oleg at okmij.org wrote:
> Tom Ellis wrote:
> > Is there a type with an Eq instance for which on Ord instance could not also
> > be provided (i.e. I'm interested in Clark's "converse")?
> 
> Of course. One of the very many examples is Complex. One can say we
> can compare complex numbers, by their absolute value.  That is true;
> however we end up in a position where compare x y returns EQ but x==y
> returns False. 

I don't understand your objection.  `Complex a` isomorphic to `(a, a)` which
can be totally ordered.  (The complex field cannot be given a total order
*compatible with the field structure*, but that's not relevant to my
question.)

> In general, Ord represents total order. There are many structures on
> which total order cannot be established. Take nodes in the tree, the
> Tree data type. One can compare nodes by taking a parent to be less
> than any of its children. But then two brothers are not
> comparable. Searching for "partial orders" and pre-orders gives many
> more examples.

I think you may be missing the intent of my question.  I am merely asking
whether there is a type which supports a (law abiding) Eq instance that
cannot support a (law abiding) Ord instance.  Whether that Ord instance is
compatible with additional structures on that type is beside the point.

Tom


More information about the Haskell-Cafe mailing list