[Haskell-cafe] Are all monads functions?

Roman Cheplyaka roma at ro-che.info
Sat Dec 31 13:52:01 CET 2011


* Yves Parès <limestrael+haskell at gmail.com> [2011-12-31 13:09:37+0100]
> One thought occur to me recently when explaining the concept of Monad to
> non-haskellers: internally, all standard Monads are newtypes wrapping
> functions:
> StateT is, WriterT is, ContT is. Even IO and ST are, both conceptually and
> in their implementation by GHC.
> ParsecT (not part of mtl, but still) is. And so on...

Writer(T) is not a function, it's just a tuple.

Jerzy already mentioned [] and Maybe.

Another example is a free monad generated by any polynomial functor.
This subsumes Maybe and (almost) [], as described here:
http://blog.omega-prime.co.uk/?p=34

To summarise, since there are only so many ways to form types in Haskell
(sum, product and exponentiation (functions)), it's no surprise that
functions do occur often, but that's not something fundamental to monads.

-- 
Roman I. Cheplyaka :: http://ro-che.info/



More information about the Haskell-Cafe mailing list