Monads and Breakthroughs

Monads and monad tutorials are notorious in the world of programmers. There are hundreds of monad tutorials which are meant to be definitive, and yet there can never be enough. Some draw upon analogy and others instead provide motivation for their design: “You could have thought of monads”, they reassure the reader. What neither focuses on, however, is the fact that you didn’t think of monads, that most importantly, monads provide a very unfamiliar outlook on familiar problems.

What does the leap toward monads require? For many readers of programming blogs, the monad is an introduction to formal algebraic structures. Maybe this is why tutorials on the subject take a reassuring voice, suggesting that monads are not so different after all. But it’s this bias toward the familiar which makes the tutorials so ineffective. The more effective presentation of monads–or any foreign concept, for that matter–leads with the unfamiliar concepts and their role. To understand the monad, you need to understand functors, categories, and algebraic structures. Consider the first concept: What’s a functor? Why is it used? The idea can be presented in a way free of analogy, building from first principles:

It is often necessary to add nuance to a value. Rather than consider it a string, you must consider it a thunk of a string or an array of strings. Regardless of the sort of nuance, in well-typed languages this value must take on a type which encapsulates it. Toward this end, functors allow us to map objects of a given type and functions interacting with the same to ones which have the same role in terms of a derivative–perhaps more nuanced–type. A monad is defined in terms of one such functor.

Establishing prerequisite concepts in this way makes clear that monads operate at a higher level than most familiar abstractions. This is good, but not because it’s humbling or impressive. This is good because it highlights the defining characteristic of monads. Relating the subject in this way lets the reader understand common problems–the same problems which many tutorials paint as the full-capacity of the monad–as instances of a greater formal construct. When relating a breakthrough concept like the monad, it should not be demoted to familiarity; rather, the author should evangelize its novelty. Its novelty is what makes it a powerful tool to think with.

When you realize that an idea as generic and yet foreign as the monad is given a foundational role in languages like Haskell, you become eager to understand it. Your worldview has been disturbed and you need to reconcile it. Many come out of this journey certain that the concept was not so foreign after all and are then eager to share their conclusion; they want to let others know that they need not worry: Haskell’s grass is no greener than JavaScript’s. Even those who go on to think in terms of high-level abstractions like this one often undermine their enlightenment: it merely gave names to concepts they had been reaching for.

This tendency to undermine the novel is of course not limited to monad tutorials. It’s common in discourse of every sort. It’s taxing to be truly open to the insights of a higher perspective, but it’s the only way to keep climbing.

 
5
Kudos
 
5
Kudos

Now read this

Idea Filters

Nowadays everything seems fungible. Discussion of the successors to credit cards and gas-powered cars is common in a way that discussion of those to paper currency and oil lamps never was. The status quo is so quickly shifting that any... Continue →