3 ms·
> Typically I don't want side-effects to all live in one thing. It's cute but "we want to change the world," don't we? I don't really understand the argument h
by lmm 5y ago
> Typically I don't want side-effects to all live in one thing. It's cute but "we want to change the world," don't we?
I don't really understand the argument here? Usually we want to properly separate concerns and make sure each thing has one responsibility. Monads are a big help with that.
Any time you have a secondary concern that you don't want to be dealing with explicitly in your straight-through code is a good use case. Any time you would be tempted to use aspect-oriented programming, or a global/thread-local variable, or similar hacks (and IMO they're still hacks when they're built into the language, e.g. exceptions).
E.g. authorization, audit logging, database transactions, error handling - rather than having to use some magical decorator/annotation/macro that breaks all the rules of your language, by using monads you can write code that uses these things as plain old functions working on plain old values, but there's an extensive library of standard operations (e.g. traverse, *M variants of functions like cataM) that you can use to make working with them almost as lightweight as if you were using the magic way.