[Haskell-beginners] Ensuring consistency in typeclass instances?

Colin Paul Adams colin at colina.demon.co.uk
Tue Nov 25 12:52:06 EST 2008


Hello,

I'm just reading through Real World Haskell - chapter 6 (typeclasses).

The definition of Eq is shown, and it mentions that you can define
either one or both of the two classes.

What would happen if I were two define both == and /= for an instance,
in such a way that they were not opposites?

If I were doing this in Eiffel, the function definitions would have
postconditions to state the relationships, and the first execution
would trigger a violation, telling me what was wrong. Is there any
similar facility in Haskell?
-- 
Colin Adams
Preston Lancashire


More information about the Beginners mailing list