Personal tools

What a Monad is not

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search

Revision as of 19:30, 23 November 2009


1 Warning


Also, don't be surprised if you leave this page more confused than before. That just means that it has successfully destroyed your false assumptions.



3 Monads are not a language feature


4 Haskell doesn't need Monads

...well, apart from the Haskell standard defining the way IO is done in terms of Monads: It could be done differently and still work.

5 Monads are not impure


6 Monads are not about state


7 Monads are not about strictness

There are monads that are strict (like IO), and monads that are lazy (like []). Then there are some that come in multiple flavours, like State.

8 Monads are not values



type Mobit m a = Monad m => m a




...and while addition and multiplication are both monoids over the positive natural numbers, a monad is a monoid in a category of endofunctors. It's all very simple.

9 Monads are not a replacement for applicative functors




10 Monads are not about ordering


> Just 2 >> Just 3

Just 3

That's not commutative in the same intutive sense as "a + b === b + a".

Commutativity, wrt. Monads, means that

(x <- a; y <- b; return (x,y)) === (y <- b; x <- a; return (x,y))

So we need some better notion of "ordering" to get to the bottom of this.