sam
02/10/2022, 7:52 PMsam
02/10/2022, 7:52 PMsequenceValidated
?sam
02/10/2022, 7:54 PMval p1: (T) -> ValidatedNel<E, A>
val p2: (T) -> ValidatedNel<E, B>
p1(t).flatMap { a -> p2(t).map { b-> Pair(a, b) } }
Wesley Hartford
02/10/2022, 8:08 PMzip
what you're looking for?
p1(t).zip(p2(t)) { a, b -> Pair(a, b) }
I think that works, not sure though.sam
02/10/2022, 8:09 PMWesley Hartford
02/10/2022, 8:11 PMraulraja
02/10/2022, 9:28 PMeither
blocks and use them as if they were of type Either
.
either<E> {
Pair(p1.bind(), p2.bind())
}
The difference is that if you bind, it would short-circuit instead of accumulating errors when any of the values is of type Invalid