2 ms·
Yes! This is exactly how I prefer to explain monads to non-Haskellers. A monad is just a unified abstraction for a certain type of callback which pops up in a b
by bradrn 5y ago
Yes! This is exactly how I prefer to explain monads to non-Haskellers. A monad is just a unified abstraction for a certain type of callback which pops up in a bunch of different places (promises, optionals, randomness etc.). In some ways, it’s almost like a formalised version of an design pattern in the OOP sense. There’s really no need for category theory or strained analogies to understand or use monads in normal Haskell code.
(Of course, the theoretical underpinnings are still very interesting in and of themselves! They’re also a source for new patterns — things like free monads and comonads are very, very useful indeed. But it’s entirely possible to program Haskell without knowing a thing about category theory; most Haskellers don’t.)