3 ms·
I like the article, though... the problems it illustrates with effects are usually solved by DI/IoC containers. It even says so: > Effect handlers let us decou
by zvrba 5y ago
I like the article, though... the problems it illustrates with effects are usually solved by DI/IoC containers. It even says so:
> Effect handlers let us decouple the program logic from its concrete effect implementations without too much ceremony or boilerplate code. For example, we could completely override the behavior in tests to use a fake filesystem [..]
Yes, I understand the fundamental difference between effects and DI (effects suspend the execution and search the call stack for the handler - like exceptions, but without immediate unwinding).
Maybe we could solve the problem with code being able to throw arbitrary exceptions by injecting an "Error" interface as well and then using some discipline? (I.e., instead of throwing stuff directly, we invoke methods on the Error interface.) Actually, I have to think more about this.
Thanks for the link, it gave me some food for thought.