FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

Andrew Wagner wagner.andrew at gmail.com
Wed Aug 1 11:31:45 EDT 2007


>
> "an IO monad is a delayed action that will be executed as soon as that action is needed for further evaluation of the program."
>

I'm not sure I like this, as it seems to confuse the issue. An expert
should correct me if I'm wrong, but monads in and of themselves don't
depend on laziness. Rather, *everything* in haskell is lazy, unless
explicitly strict-ified.

As for the rest of your email, I don't necessarily disagree, but don't
find it particularly helpful either. Which may, of course, be a
personal thing. For me, I think the key to monads is to really
understand 2 things about them:
1.) They are simply type constructor classes
2.) Monads are about sequencing

For point 2, think about the two main things you have to define to
create an instance of a monad:
(>>=) :: m a -> (a -> m b) -> m b

That is, you have two monadic actions, m a and m b, and bind says how
to take the result of the first and fit it into the second -- in
sequence!

(>>) :: m a -> m b -> m b

Again, we have 2 monadic actions that we're composing, in sequence.
This time, we're just discarding the result of the first.


More information about the Haskell-Cafe mailing list