
2008/8/21 Sean Leather
This in response to a comment on a GHC ticket [1]. I thought it was interesting enough to warrant general discussion.
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?
Yes, it's in development, called 'checkers'. code.haskell.org/checkers Luke