Monads for Normal Programmers

  • These "monad tutorials" drive me nuts. I wasted a week trying to understand monads from random "You can do monads in Python, JavaScript and Brainfuck!" tutorials that all had different (and sometimes inconsistent) perspectives on what they were and what they were good for before I gave up and learned Haskell. In my case, I was laboring under the false assumption that because I knew language X, it would be easier to learn about monads in X than to learn Haskell. In Haskell, the value of monadic computation falls out naturally from the type system and syntax. Yes, you still have to verify the laws, but Haskell's purity makes this easier as well.

    I think the jQuery analogy has some didactic value for understanding combinators, but calling it a monad and falsely asserting that the laws hold is not doing "normal programmers" any favors. In the comments, he analogizes demonstrating the map function to C programmers, but this analogy is false because he clearly understands map and what it's used for but the same cannot be said for his understanding of monads.

    For "normal programmers" out there who want to (for whatever reason) learn about monads, my recommendation is to ignore these tutorials and learn Haskell or an equivalent. I learned Haskell specifically to develop an understanding of monads, but what I got out of it was much, much more valuable than just an understanding of monads.

  • > A Monad is an object whose methods return monads.

    This is exceptionally wrong.

  • The guide that I've looked at in the past and had success with is http://blog.sigfpe.com/2006/08/you-could-have-invented-monad... - I got this from a prior HN post.

  • Craft of Christ, jQuery is not a monad. Ever since the first disgraceful post to that effect, people have been spreading this utterly false rumor and confusing the people they are supposed to be teaching.

  • Uh, these are not monads. These are actually what we might call "wrappers". They just provide a nicer interface for an underlying API (the DOM in jQuery's case, and sql queries in Django's).

    What is a monad is JQuery.Deferred, with the `.then(...)` method as the `bind` operator. This has to be monadic, because it wraps a promise of a value that can't be computed synchronously.

  • The simplest starting point for C++/Java programmers is the question: "what if the ';' was an infix operator that you can redefine?"

    Then most of them start to understand the power of the concept.

  • If this is all there is to monads the functional community needs to level up their communication experience and/or allow themselves to stop talking in terms of type theory.

  • He obviously did not read this article, which was popular on HN a few days ago: http://www.jasq.org/2/post/2013/01/the-mathematician-the-mon...

  • A monad is an object whose methods return: either itself if that method is not meant to change the object's properties, like getters; or a new copy of original monad object with changed properties if that method is meant to change object properties, like setters.

  • Here is (another) nice video about monads: http://vimeo.com/album/2206951/video/20717301

  • I think that monad is actually the "." in the OO world. This is because in my view the monad actually sits in between the functions and controls the function combinations and the value between the threading. So for instance Maybe will decide whether to really call the next method based on the value itself (like null). Or I maybe wrong :)

  • "Monads for JavaScript Programmers"

    Just as the talk he refers to (I've seen it and it's ok)... It's for JavaScript programmers):

    https://www.youtube.com/watch?v=b0EF0VTs9Dc

    So unless there's a 1-to-1 mapping between "Normal Programmers" and "JavaScript" programmers this title is quite misleading.