September 2023
Intermediate to advanced
470 pages
11h 12m
English
The main topic of this chapter is exploring ways to compose functions together. For our first example, let’s consider the function we’ve just written—retrieveOldAndNewListName. This is the piece of code where we combined two readers and returned a tuple with their results:
| | // retrieveOldAndNewListName |
| | eventStore.retrieveByNaturalKey(UserListName(user, oldName)) |
| | .bind { currList -> |
| | eventStore.retrieveByNaturalKey(UserListName(user, newName)) |
| | .transform { newList -> currList to newList } |
| | } |
Is there something more generic that can be extracted here? Let me show you a good technique—let’s extract local variables for each functor and the combining function:
| | // retrieveOldAndNewListName |
| |
Read now
Unlock full access