Comment (by JeremyShaw):
> Also, where does the H98 report say all instances of Eq must be
transitive, reflexive, symmetric, and antisymmetric? It just says "The Eq
class provides equality (==)..", whatever that might mean :-)
Well, it does not say it explicitly, but I suspect H98's usage of Eq
implicitly demands those laws be followed.
Indeed. The same goes for the implicit law that (x /= y) /= (x == y), since both (/=) and (==) can be overridden. [2]
Hopefully in Haskell' the laws
will not only be stated, but there will be some QuickCheck-style
properties you can use to test your own instances ;)
This is an interesting thought. Has there been any work towards collecting properties written with QuickCheck (or similar) into a reusable chunk of some form? It would be very convenient to have parametrized properties that tested implicit laws such as equality, monads, and other things that come with the Haskell Platform. Not only would such a library be useful to use, but it would provide a number of readily available examples for would-be testers, thus encouraging testing.
Sean
[1]
http://hackage.haskell.org/trac/ghc/ticket/2528#comment:6[2]
http://www.haskell.org/tutorial/monads.html#sect9.1