State monads don't respect the monad laws in Haskell

George Russell ger@tzi.de
Tue, 14 May 2002 17:32:56 +0200


Dylan Thurston wrote:
[snip]
> I've often been bothered by the inconsistent treatment of laws in the
> report; why are there laws for functors, monads, and quot/rem and
> div/mod, and not much else?  I'm pleased to see that the laws that are
> given actually do have exceptions.
[snip]
Even the quot/rem and div/mod laws are not always true, for example if you
divide by zero, or (for div/mod, where overflows cause an error) where
you get an overflow with (x `div` y) * y.  Perhaps we need something in the
report to state that these laws like these and the Monad laws are only intended
as aspirations rather than promises.