Singular Type Constructor

Ashley Yakeley
Sun, 12 Aug 2001 17:58:36 -0700

At 2001-08-12 16:55, Hal Daume III wrote:

>but supposing you wanted a sort of relaxed equality
>wherein, if you chould check for equality on the second element, you
>would, otherwise you would just check the first element.  i would want
>to say something like:
>instance (Eq a, Not (Eq b)) => Eq (MyPair a b) where
>    (MyPair a _) == (MyPair a' _) = a == a'
>But from what you're telling me there's no way to have both of these
>instances, correct?

There's no 'Not', so you can't have the second one. If you had a 'Not', 
it would allow some ugliness:

data PQ = P | Q

equalPQ = (MyPair 'a' P) == (MyPair 'a' Q)

Note that equalPQ is True. But if someone else introduces an "instance Eq 
PQ" in another module, equalPQ could become False. I think this sort of 
thing is supposed to be prohibited: code that is correct cannot change 
its meaning due to modules it does not depend on.

Ashley Yakeley, Seattle WA