You Could Have Invented Monads (And Maybe You Already Have)
blog.sigfpe.com
blog.sigfpe.com
Well, it would have been a surprise, but I just spoiled it. Anyway, get reading :)
I actually had déja vu because I had written code very much like this before in Haskell. It got ugly real quick, and I remember thinking 'there has to be a better way of doing this'. Turns out I was right.
(Everyone should read Meet The Monads and the Typeclassopedia, of course.)
The guy who wrote the Typeclassopedia (Brent Yorgey) is coming to speak to my local functional languages group up on campus tomorrow. In the process of googling him, I came across both the Typeclassopedia and this article, and both were excellent.
This tutorial was just one of the those "aha!" moments in my life, and I wanted to share.
http://blogs.msdn.com/wesdyer/archive/2008/01/11/the-marvels...
Actually, now that I think about it, it seems to me that pythonic monads should really be context managers, so they can be used like:
with SomeMonad:
do stuff