Everything Your Professor Failed to Tell You About Functional Programming

My Google Alert on Haskell tortured me with weeks of unrelated news about folks called Haskell, sports results from a college of the same name and local incidents from a town of the same name. Finally today I got a on-topic hit. Allow me to share it with you, it is here.

PS Is this is the proper way to submit some interesting link?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Links

PS Is this is the proper way to submit some interesting link?

Sure. That's fine.

People who frequently have news to post should consider becoming contributing editors, which essentially means being able to post to the home page.

Nice summary

I quite like that article. I was always baffled by Monads, and the thing that baffled me was, I was expected deep magic but really there isn't much to them. As the article says, they are just a design pattern.

Took Me a While!

It took me a while to grasp that, too. A crucial thing to aid my understanding was the observation that even Haskell doesn't (can't?) enforce the monad laws: the Monad type, do-notation, and related machinery are just conveniences. Once you "get" that a monadic type constructor just returns a higher-order function and the other functions just manipulate those HOFs according to the monad laws, things become a bit clearer. Once you play with monadic implementations in a few different languages (Scheme, O'Caml, even C++...) things become clearer still.

Of course, the joker in the deck, as I've written before, is that, at least for me, monads never get any easier to understand than HOFs do, and for a great many programmers, myself included, HOFs themselves carry what feels like an irreducible level of complexity to them. I've been programming in languages in which functions are first-class for over two decades now, and I still find myself learning things about HOFs all the time!

Picking some nits

Once you "get" that a monadic type constructor just returns a higher-order function and the other functions just manipulate those HOFs according to the monad laws, things become a bit clearer.

Where is the higher-order function (specifically: the one that is returned) in the Maybe monad? Also, type constructors return types. (Let's not make monads even more difficult to understand.)