http://qs1969.pair.com?node_id=758127


in reply to Re: Functional programming ?
in thread Functional programming ?

I suspect that few understand monads well enough to get your analogy.

The short explanation is that in pure functional programming, every time you call a function with a fixed set of arguments, you must get the same response back. But if you do I/O, you want it to do a different thing each time. Monads are used to solve this problem by creating a container that will be a different argument each and every time you call the function, which therefore makes it OK to get different results back. In the above analogy, therefore, the truck is the monad. And every time you make a delivery, you need a different truck.

Monads can be used for other things as well, but this is the one that first confronts anyone learning Haskell.