[Haskell-cafe] Class invariants/laws
voigt at tcs.inf.tu-dresden.de
Thu Oct 18 03:47:41 EDT 2007
ajb at spamcop.net wrote:
>> Agreed. I was about to answer that the situation is the same with the
>> monad laws not being valid for some monad we all love, and still we do
>> not consider the resulting programs illegal.
> I do! The H98 report says that all Monad instances must obey the monad
> laws. If they don't, they're illegal.
Okay. I wasn't aware that the report makes this mandatory.
> In general, it'd be nice to be able to get the compiler to check that
> you've implemented at least a minimal set of operations in your class
Yes. But actually what we would need would be that it checks as well
that we have implemented at *most* a minimal set of operations.
Otherwise, we are back to the point where I can implement both (==) and
(/=), and in a way that the supposed invariant is broken.
Dr. Janis Voigtlaender
mailto:voigt at tcs.inf.tu-dresden.de
More information about the Haskell-Cafe