[Haskell-cafe] Wow Monads!

Joachim Durchholz jo at durchholz.org
Mon Apr 17 08:58:45 UTC 2017


Am 16.04.2017 um 23:07 schrieb David McClain:
> Heh!! My title “Wow” was not an expression of wonderment. Rather it
> was “Holy Cow! Monads, how can you guys be so obtuse?!”

LOL okay :-D

I think they suffer from being awesome even if not well-understood, so 
half-true statements about them get widely distributed.

What I still don't know is if their face value is overhyped or not.

The paper essentially displays how to do the visitor pattern in a 
functional way. Nothing to see here, move on...
There are a few interesting aside points though:

One, that this kind of injection can be done in a type-safe way (not a 
mean feat given the complexities of type parameters, but essentially 
follows from the choice of type system and, interestingly, the absence 
of side effects). This point is unrelated to monads, it's entirely 
conceivable that some other structure could have been used instead.

Two, that the set of changes needed to turn a straightforward expression 
tree into an injectable one is so small. It's a mixed blessing, because 
the actual complexity of the definition is much larger than what you see 
at a glance. However, it's unrelated to monads as well, it's a 
consequence of having type inference and currying.

Three, that the injected structure does not need to be more than merely 
conform to Monad, which is a pretty small core API (with "core" I mean 
the set of functions that cannot be expressed as composition of other 
API functions).
Now this is indeed related to monads, but to me, it's unclear how 
important that finding is. I see monads being found all over the place, 
but is that a consequence of the Monad structure being so simple and 
permissive that it happens to match so many places in so many programs, 
is it because there are useful monad libraries that people actively make 
their code conform to the structure, is it perception bias (because 
monads are well-discussed so people can identify a Monad in their code 
but not an Arrow), or is Monad indeed tied to fundamental properties of 
coding? Frankly, I don't even know how to test the hypotheses here.
What I do know is that we had a quite overhyped, simple but ubiquitous 
data structure earlier: Lists. In the 80ies, there was that meme that 
lists are the universal answers to data structures, mostly from the Lisp 
camp where lists were indeed fundamental, ubiquitous, and so simple they 
could be applied easily to all tasks. I haven't seen anybody seriously 
entertaining that thought in years; it will be interesting to see 
whether monads share that fate or prove to be something more fundamental.

Just my 2 cents :-)


More information about the Haskell-Cafe mailing list