Moved to https://github.com/kbilsted/Functional-core-imperative-shell/blob/master/README.md
-
-
Save kbilsted/abdc017858cad68c3e7926b03646554e to your computer and use it in GitHub Desktop.
I encourage you to read about exception handling. There's nothing much to it.
https://redux-saga.js.org/docs/basics/ErrorHandling.html
Then you could put errors on the so called "root" as well.
Like I said, nothing much to it. The generator pattern is powerful.
@maletor thanks, essentially you just removed the ability to throw an exception one place and catch in another by marking it an explicit codepath which you need to cater for all the way from your catch-statement down to your throw statement.
should we convert part of this debate into text somehow? Should I convert this gist to a repo so we can grow this resource together?
(You also get concurrency for free with generators - by yielding an array of promises: https://amphp.org/)
(And another aspect with effects-as-promises is that you can mock the effects instead of the dependencies when designing your tests. The downside being that you bind the test more tightly to your implementation. But there are several upsides as well - e.g. testing only certain types of effects, being able to ignore all effects, and less mocking code.)
should we convert part of this debate into text somehow? Should I convert this gist to a repo so we can grow this resource together?
Dunno. The pattern would have to be tried out in a bigger application, I think, before knowing if it's applicable.
Oh, you already made a repo. Nice. :)
@kbilsted Both exception handling and division by zero is not dealt with here, I think. You can check out experimental programming languages like Koka and F* that deal with this properly. Again, this does not enforce functional core, only more side-effect discipline. It Koka, they mark a difference between total and pure functions, the latter allowing both exceptions and division by zero.