News for hackers. Stuff that matters.
Re:Ask HN: Are Monads Really That Hard? by jonsterling on Friday November 16, 2012 @01:47AM (#4792759)
Sigh. A type `m` is a "monad" if a few functions can be written for it with the following signatures (there are some laws too, but just ignore those until you understand the basics):

    return :: a -> m a
    bind :: (a -> m b) -> m a -> m b
That's all it is. What you've described is a particular type for which these functions can be written.

My advice: stop trying to think of particular ways monads can be used. Rather, you need to understand it as embodying a special flavor of embedding values and functions from one space (the space of simple types a, a -> m b) into another (the space of types m a, m a -> m b).

So, bind, apply and map are just ways of lifting different-shaped functions into (m a -> m b):

    map   :: (a -> b)   -> (m a -> m b) -- from Functor
    bind  :: (a -> m b) -> (m a -> m b) -- from Monad
    apply :: m (a -> b) -> (m a -> m b) -- from Applicative
The moment you start trying to understand these with some first-order metaphor, you know you've lost the way! :)

There are no comments on this comment yet.