Closed diogob closed 3 months ago
@diogob , I'm good with having it but the name doesn't do it for me... hard to tell what it does, especially because we have sequence
and all
and it has nothing to do with them. WDYT?
@diogob , I'm good with having it but the name doesn't do it for me... hard to tell what it does, especially because we have
sequence
andall
and it has nothing to do with them. WDYT?
I actually derived the name from both, since it takes the typing of all
but most of the implementation from sequence
. You could say that this is a serial version of the all
combinator.
Other possible names along these lines would be:
allInSequence
allInSeries
serialAll
tap?
Use case
This fits a similar use case as the passthrough proposed on #96 It can be used to add validation functions to a pipeline that should abort execution on error but don't necessarly produce a result that we want to pipe to the next callee.
For instance, let's say you want to check the state of a record in the database and send a notification only when the validation function is successful. In this case the resulting type of the validation function should not be taken into account, since you don't want to write the function for the composition.
With the new combinator something like this could be done:
It also makes it easier to reuse existing functions just for the sake of their side-effects. On the previous example, let's say you want add a function that records a log of messages sent on the database (and fail to send the message in case the log fails).
I was hoping to merge this before we have the full composable documentation.
TODO