I don't want to be too hard on this guy, but this is a bad article. Sorry. This article uses incorrect terms to define things. It also doesn't explain or illustrate why monads are useful. You cannot read this article and learn anything about monads.
It's not useful on a theoretics level, and it's also not useful on a practical Haskell level. I don't think the author understands what he is writing about. (Don't get me wrong, by the way – it's totally fine to write about something you don't understand in order to learn more about it. But maybe don't publish it prominently on your website and peddle it out to newbies as learning material.)
The overabundance of bad monad articles is making it harder for Haskell newbies to learn. There are many good, free resources for learning about Haskell, such as Real World Haskell. This is not one of them.
Think of a monad as a spacesuite full of nuclear waste in the ocean next to a container of apples. now, you can't put oranges in the space suite or the nucelar waste falls in the ocean, BUT the apples are carried around anyway, and you just take what you need. - Dons, talking about bad monad explanations
edit: also, if you're really interested in seeing what a Haskell monad looks like literally translated into JavaScript, I wrote a comment here on HN a year ago with some code: http://news.ycombinator.com/item?id=1275860 I could leave better comments if I wrote it again today, but the code is correct and works.
You see, I already sensed that monads:
- were a way that you could sort of simulate side effects using pure functions
- had to do with the type signatures of functions
What I gleaned from the article is that monads:
- have to do with making functions composable
- work by way of the abstractions bind and unit in order to make type signatures match
Did the article harm my (lack of) understanding of monads?
For a "state" monad, that calculation is maintaining/passing the state. For a "logging" monad, that calculation is maintaining the log. For an "error handling monad", that calculation is checking for and propagating errors.
monads are not for simulating side effects. they can model many things.
functions are already composable with the dot (.). if you want to compose arbitrary structures, use Control.Category.
unit does not have anything in particular to do with monads.
'bind' is specific to each monad and defines its behavior. there is no abstract or generic bind.
the article didn't teach you anything.
ask #Haskell on freenode if you have questions.
While Haskell -> Javascript has been done before, all the examples seem toys without a rich integration into the browser.