September 2023
Intermediate to advanced
470 pages
11h 12m
English
The exercises in this chapter will focus on how to combine multiple outcomes using applicative functors.
Here is your friendly reminder that nobody can learn functional programming by just reading code, and the best way to learn is by practicing. You can refer to the exercises folder in the book code repository for the starting point and some hints.
We defined reduce for combining failures, but it can be done for successes as well. For this exercise, try to implement this function in a way that it will return the reduction of all outcomes in a success if they were all successful or in an error if at least one was a failure:
| | fun <E : OutcomeError, S, T: S> List<Outcome<E, T>> |
| | .reduceSuccess(f: ... |
Read now
Unlock full access