Cody Mikol
04/15/2021, 3:21 PMIterable<Either<L,R>>
into a Validated<Nel<L>, R>
?
For more context, I’m using parTraverse on a collection, returning an Either<L,R>
for each item. I’d like to collect that into a Validated<Nel<L>,R
to that I can take the left path if there are any errors and collect that into some useful log message.
It looks something like
items
.parTraverse { doWork(it, foo) }
.toValidated() // This is what I'm trying to figure out.
.mapLeft { makeErrorMessage(it) // where it is Nel<L> }
fun doWork() : Either<L,R>
Alex Johnson
04/15/2021, 4:13 PMsimon.vergauwen
04/15/2021, 4:19 PMparTraverseValidated
.
items .parTraverseValidated(Semigroup.nonEmptyList()) {
doWork(it, foo).toValidatedNel()
}
Cody Mikol
04/15/2021, 8:48 PM