Closed flakey-bit closed 2 years ago
sorry for the enormous delay in answering... how would this differ from Option.sequence
?
right, you'd like that it returns none only if all of the options are none... while sequence returns none if any of the options is none. I don't think about that as accumulating like we're accumulating lefts with either.
i don't know, this doesn't feel like a standard function. I'd say if you need it, you can implement it in your code. maybe if you can find a relatively known library where it's implement, it would change my mind...
Would it be possible to implement
sequenceAcc
for Option? Like you have forEither
?Could be used for validation - let's say you have a bunch of functions that - given some input - perform a validation and return
Option<TValidationError>
.You want to apply all of those validation functions and get out an
Option<TValidationError[]>
. If none of the validation functions produce an error then the outcome would benone
.Something like this: