Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
You Could Have Invented Monads (And Maybe You Already Have) (sigfpe.com)
34 points by Xichekolas on Nov 24, 2009 | hide | past | favorite | 6 comments


In addition to this, another great Haskell+monads learning source is Real World Haskell, whose exercises will have you implement your own monads without telling you, and then reveal the surprise later.

Well, it would have been a surprise, but I just spoiled it. Anyway, get reading :)


This is the explanation of Monads that made it click for me.

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.


The only blog-style "monad tutorial" anyone should read.

(Everyone should read Meet The Monads and the Typeclassopedia, of course.)


Funny you should mention the Typeclassopedia.

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.


Another excellent introduction to monads for experienced imperative programmers, particularly those familiar with C#, is here:

http://blogs.msdn.com/wesdyer/archive/2008/01/11/the-marvels...


Here is my favorite monad tutorial: http://www.valuedlessons.com/2008/01/monads-in-python-with-n... . The reason I like it is because it uses Python rather than Haskell while pointing out that you can build monads in any language that supports objects or closures.

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




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: