[Haskell-beginners] WWAAA... I hate monads

Sergey V. Mikhanov sergey at mikhanov.com
Wed Apr 22 08:01:28 EDT 2009


> 1) Am I right in thinking that any type with two elements ("m a") is always
> a Monad? (IO String, Maybe Int, etc).
>
> 2) When I say "m a >>= f" the >>= just pulls the "a" out of "m a" and passes
> it to "f". Right?
>
> 3) The last two properties are not comparing values but functions. Right?
> For example, reading the second-last property:
>
> (m >>= return) :: a -> m a
>
> Where (m >>= return) is defined by (\x -> m x >>= return). Right? And this
> is why you can write the last property:
>
> (k >>= h) :: a -> h a defined by (\x -> k a >>= h) This is what allows us to
> make (k >>= h) the second argument of ">>=" as in the last property:
>
> m >>= (k >>= h) == (m >>= k) >>= h
>
> Am I right?

I am also a beginner, so you should take my words with the grain of
salt. Strange enough, the monad description that helped me most is the
Wikipedia article:

http://en.wikipedia.org/wiki/Monad_(functional_programming)

This basically answers some of your questions by defining monad as
triple (type constructor, bind function and return function), with
certain properties.

S.


More information about the Beginners mailing list