Learning about Monads through jQuery
While doing some introductory reading about Haskell, I’ve been stumped by monads. It’s a pretty abstract concept related to functional programming that I’ve been trying to wrap my mind around. There are articles here and there that try to explain it, but the bottom line I’ve been looking for? How do I use it?
Well, it looks like I found a good article to break that barrier. If you know javascript and are familiar with jQuery, you can get in on the fun, too.
It’s said that every Haskell programmer writes their own monad tutorial, and with good reason: once you finally understand the definition and capabilities of a monad, you’ll be eager to try and break the mystique surrounding the concept of monads as a whole. To the outsider, monads are an impenetrable barrier to truly understanding Haskell; they’re cursed with a very unfortunate name, have bizarre syntax, and seem to do a thousand things at once. However, monads aren’t hard to understand when you see them in action.
The above is from Patrick Thomson, who writes how jQuery functions like a monad. The concepts we’ve been putting to use in this excellent javascript library have been whetting our appetites for monads all along. Of course, it can get more complicated and glorious than that, but this is how knowledge works…building on what we already know.
This also contributes to my growing suspicion that out of the two heavyweight champs of javascript libraries (the other being Prototype/Scriptaculous), jQuery is the “better” abstraction. More on that later.