[Haskell-cafe] Monad Description For Imperative Programmer

david48 dav.vire+haskell at gmail.com
Wed Aug 1 09:59:35 EDT 2007

On 8/1/07, Andrew Wagner <wagner.andrew at gmail.com> wrote:

> > you can imagine each of the calls to putStrLn gets implicitly passed a
> > variable (here, the world ) and they happen in succession so it's
> > "like a loop".

> It breaks down further as soon as you add any amount of complexity to
> the code as well. E.g.:
> Not loop-ish at all!

I totally agree I was just stating how I understood the original
poster's statement :)

Personally I showed haskell to a Friend last week end.
To explain some monadic code I explained it somewhat this way ( please
keep in mind that I'm a beginner so the explanation I gave him is
probably not accurate )

I told him that in a lazy functional programming language you can't
decide when a function gets evaluated or not.
I then told him that it gets problematic if you want evaluate some
functions in sequence.

I also told him that haskell is a pure language, that is there is no
side effects in the functions.
I then told him that it's a problem if you want to interact with the
outside world (IO)

I explained that a monad is a way to get functions evaluated in a
specific order, with a type such that you can't mix actions with pure

I told him that monads are just a special datatype and implementation
of 2 functions :
- a function that lets you evaluate a function before evaluating the
next one, taking the output of the first function to feed the input of
the second.
- a function that takes a pure value and "promotes" to the monad's type.

I told him that in the case of IO the datatype in question is IO and
it contains data about the outside world, but there are many other
monads, but I didn't go there too much because it's not totally clear
for me.

He seemed to be not too much confused by the concept, so I hope that I
didn't told him too much inaccuracies...

More information about the Haskell-Cafe mailing list