[Haskell-cafe] Suggestions For An Intro To Monads Talk.

wren ng thornton wren at freegeek.org
Mon Aug 9 05:33:31 EDT 2010

aditya siram wrote:
> Thanks all for you suggestions!
> Upon further reflection I realized that my audience is more pragmatic than
> theoretical. Instead of emphasizing how monads are constructed and the monad
> laws I think I want to dive right into the most common and useful monads.
>>From my vantage point they are (in no particular order) : Reader, Writer,
> State, IO, ST, STM, Parsec (have I missed any?) and of course the
> transformer versions. I am debating whether or not to add [] to the bunch.

Whether you add [] or not, you should definitely include Maybe. Maybe 
captures the most basic kind of fallible computation, so it shows up all 
over the place with pragmatic coding. Compare against null pointers, 
returning -1 to signal error when a positive number is the expected 
return, using 0 to express an infinite limit on some kind of resource, 
etc. Maybe does the same thing, except it does them cleanly and 
correctly because we express the possibility of failure in the type 
system instead of relying on "magic values" to express them. Magic 
values are even worse than magic numbers and other magic constants, IMO.

Once you've explained Maybe, you can mention (Either a) in passing; they 
should figure out the generalization immediately.

Live well,

More information about the Haskell-Cafe mailing list