Monads

Jerzy Karczmarczuk karczma@info.unicaen.fr
Thu, 17 May 2001 11:03:22 +0200


Ashley Yakeley answer to Mads Skagen:

> >My question is why are monads necessary in the
> >language ?
> >
> >Is it not possible to construct the features provided
> >by Monads using basic functional constructs ?
> 
> Monads themselves are made purely out of basic functional constructs.
> 
> >What do I gain using Monads ?
> 
> They happen to be a very convenient pattern. Mostly they're used to model
> imperative actions: while a purely functional language cannot actually
> execute actions as part of its evaluation, it can compose them, along the
> lines of "AB is the action of doing A, and then doing B with its result".
> Monads happen to be a useful pattern for such things.

PLEASE!!!

I disagree quite strongly with such severely limited answers addressed to 
people who don't know about monads.

Monads are *much* more universal than that. They are "convenient patterns"
to code the non-determinism (lazy list monads), to generalize the concept
of continuations, to add tracing, exceptions, and all stuff called
"computation" by the followers of Moggi. They are natural thus to construct
parsers. Imperative programming is just one facet of the true story.

Mads Skagen: please read the paper by Wadler on the essence of functional
programming, and other stuff picked, say, from here:

http://hypatia.dcs.qmw.ac.uk/SEL-HPC/Articles/FuncArchive.html

That's right you don't really NEED monads (unless you are forced to do
IO...), but when you learn them you will feel better and older.


Jerzy Karczmarczuk
Caen, France