
Paul Moore wrote:
One thing I haven't found a really good discussion of, is practical examples of building monads. There's plenty of discussion of the IO monad, and the state monad, and a lot of good theory on monads, but although I've seen tantalising statements about how powerful the ability to define your own monads can be, but no really concrete examples - something along the lines of
- here is problem X - this might be our first cut at coding it - we can abstract out this stuff, as a monad - see how the code looks now, how much cleaner it is
Maybe you could try going in the opposite direction, and convert something like monadic parser combinators... http://www.cs.nott.ac.uk/~gmh/bib.html#pearl ...it into their non-monadic form (explictly passing the parsed string around).
I've only skimmed - so pointers to areas in these documents I might have missed would be appreciated. On the other hand, pointers to papers I've missed altogether would also be gratefully received.
I found the papers by Philip Wadler to be the most helpful... http://homepages.inf.ed.ac.uk/wadler/topics/monads.html ...especially _Monads for functional programming_ and _Imperative functional programming_. Greg Buchholz