How can I do applicative traverse collecting failu...
# arrow
s
How can I do applicative traverse collecting failures on left hand side ? it was possible in 0.11.0 if I remember correctly, but I can’t seem to write it in the new version. from
List<A>
to
Either<List<B>, List<C>>
just like we do for validated We only have parTraverse and parTraverseEither. So I can either get
List<Either<B, C>>
or
Either<B, List<C>>
r
Hi @Satyam Agarwal do you have a small example of the code you are trying to port from 0.11?
traverse
is available for a few data types and it no longer requires the applicative instance because it always ends in
List<F<A>>
s
I’ll check if I can find it. all my apps are now on 0.13.1 😅
Actually I had it wrong. With applicative there was always
mapN/tupledN
, so I was doing something like this :
Copy code
val re: Either<NonEmptyList<Int>, Tuple3<Int, Nothing, Nothing>> = Validated
    .applicative(NonEmptyList.semigroup<Int>())
    .mapN(1.valid(), 2.invalidNel(), 3.invalidNel()) { (a, b, c) -> Tuple3(a, b, c)}
    .fix()
    .toEither()
But I am looking something like this for parTraverse as I have a list to traverse over.
r
those are now called
zip
and the ones for
ValidatedNel
already imply you are using the Nel semigroup so you no longer ni to add it as argument
s
Yes, I can go from
parTraverseValidated
and then convert to either. Thank you 🙂
👍 1