Emil Kantis
12/03/2021, 10:03 PMEither.leftOrNull()
? For instance if I have a List<Either<A,B>>
and want to map that into a List<A>
?Emil Kantis
12/03/2021, 10:44 PMval unpackedProblems = problems.mapNotNull {
when (it) {
is Either.Left -> it.value
else -> null
}
}
Satyam Agarwal
12/04/2021, 4:08 AMSatyam Agarwal
12/04/2021, 4:08 AMIvan Lorenz
12/04/2021, 2:24 PMValidatedNel<A, B>
 :
val unpackedProblems = problems
.map { it.toValidatedNel() }
.sequenceValidated()
.tapInvalid { //consume your NonEmptyList of A typed errors }
Emil Kantis
12/05/2021, 12:07 PMresults
.map { it.toValidatedNel() }
.sequenceValidated()
.tap { generateResultEmail(it) }
.tapInvalid { generateProblemEmails(it) }