Verity Stob Teaches Functional Programming
The discussion continues with rules: variable immutability, function purity, curryability and monadicity, which is where things really go off the rails. Property 7 dribbles to a shuddering halt with,
“All monads define a
map()and a type constructor function called…
“Wait a minute. Wait a minute. Perhaps
bind()is a functor not a function. I’m pretty sure about that. Hold on to the horses a moment there while I look it up.
“…And I should perhaps clarify that this
map()is nothing to do with any other
map()methods or functions that you might be familiar with, although their actions are in some sense quite similar.
“Summary: It has been an honour and a pleasure to clear all that up for you.
“Final Reader’s comment: My gratitude is inexpressible.”
Which is not to say that I don’t enjoy immensely the functional aspects of C#. I do. I also have read a lot about monads and am completely familiar with the tragically bad and unenlightening explanations. Stob captures this elegantly with the following corollary to Rule 4:
↩“If you should by some accident come to understand what a Monad is, you will simultaneously lose the ability to explain it to anybody else.”