Monads For The Rest Of Us
Virtually all the tutorials on Monads introduce them only after a lengthy discussion about Functors, and often resorting to intrepid and debatable metaphors.
I dare to take a different path and to go straight to the point, following what Mike Vanier did in his seminal 8-post series Yet Another Monad Tutorial.
I challenged myself to write a post that:
- prioritizes code over storytelling
- uses no metaphors (no boxes, no burritos)
- does not require Category Theory
- jumps past the discussion why Functional Programming is valuable
- does not follow the classical Functors -> Monads narrative
- is tailored for C# developers and digestible by Java ones
Table of chapters
- Chapter 1: in which you realize that Monads are not things
- Chapter 2: in which you sense that it’s all about function composition
- Chapter 3: in which you reimplement — and finally understand! — C#’s function application
- Chapter 4: in which you liberate C# from IO side effects
- Chapter 5: in which you make C# nondeterministic
- Chapter 6: in which you kill null
- Chapter 7: in which you discover that Bind is a combinator and you feel illuminated
- Chapter 8: in which you achieve true enlightenment seeing that Functors are not boxes
- Chapter 9: In which you see how easy functors are, and you find inner peace
References
Mike Vanier - Yet Another Monad Tutorial
GitHub Discussions