[Haskell-cafe] Monad laws

ajb at spamcop.net ajb at spamcop.net
Thu Sep 7 23:57:33 EDT 2006

G'day all.

Quoting Deokhwan Kim <dk at ropas.snu.ac.kr>:

> What is the practical meaning of monad laws?

Interesting philosophical question.  There will be an article on
this topic in the next The Monad.Reader, so watch this space.

> But what practical problems can unsatisfying them cause?

Pretty much the same as any practical problems that occur when you
break invariants.  What problems do you cause if you don't maintain
your binary search trees in sorted order, for example?  Basically,
you break anything which depends on the laws.

For example, breaking any of the monad laws implies breaking the
functor laws (exercise: prove this), so fmap breaks.  Monad
transformers may depend on the underlying monad to satisfy the
laws, so you break stacked transformers.  Using non-conforming monads
as Kleisli arrows break the arrow laws.

Any and all of this may result in programs which misbehave.

Andrew Bromage

More information about the Haskell-Cafe mailing list