Re:Monads Are Not Metaphors (2010)
by AnimalMuppet on Thursday September 10, 2015 @01:01PM
(#10199202)
If you're in a pure functional language, monads are the way you do sequencing while still being purely functional. If you regard pure functional as the "better" (for reasons of, say, controlling the state space explosion of your code, or reasons of understandability and therefore maintainability), then monads are part of the necessary tooling to get you there (if your problems have any parts at all that are necessarily sequential).
As far as other uses: The best explanation that I've seen is that they let you hide the parts that you need to do, but that aren't the real thing your doing. Logging, for instance. You can add logging to something, and just string functions together as if there were no logging going on. (Of course, if you were doing non-pure-functional programming, you could just add logging statements wherever you wanted, and string your functions together just the same...)
As far as other uses: The best explanation that I've seen is that they let you hide the parts that you need to do, but that aren't the real thing your doing. Logging, for instance. You can add logging to something, and just string functions together as if there were no logging going on. (Of course, if you were doing non-pure-functional programming, you could just add logging statements wherever you wanted, and string your functions together just the same...)