[Haskell-cafe] ordNub
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Thu Jan 1 13:24:54 UTC 2015
On Mon, Jul 15, 2013 at 11:21:39PM -0400, Clark Gaebel wrote:
> As a tangent, can anyone think of a data structure for which you can
> write an Ord instance but Hashable/Eq is impossible (or prove
> otherwise)? How about the converse?
A conversation on #haskell brought back to mind this question, which I'm not
sure was ever answered.
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")?
One answer is that I could write
data A = A deriving Eq
and then not export the constructor. That would make it impossible to write
an Ord instance. However, I'm more interested in the question "morally" or
"in principle".
If we think about algebraic datatypes built from sums and products of base
types, which have both Eq and Ord, and the function type construct, which
prevents both Eq and Ord, it seems that the two always go together, in
principle.
Am I missing anything more exotic? IORef's have Eq but not Ord. Is there a
good reason for that? Would Ord break "referential transparency" somehow?
I doubt it. How about STRef? It seems more likely they shouldn't have Ord.
Any thoughts?
Tom
More information about the Haskell-Cafe
mailing list