the perennial List<Either<A,B>> questi...
# arrow
t
the perennial List<Either<A,B>> question comes up again - promise I have searched the archives! Have successfully used traverse with NEL to get
Copy code
Either<NonEmptyList<A>,List<B>>
But can't figure out the "arrow way" to partition List<Either<A,B>> but retain all data. e.g. into separate List<A> and List<B>, or alternatively a Tuple2<List<A>,List<B>>
can call filterMap twice, and that works fine, so mainly wondering if that's "best practise" ?
j
You could use unalignWith from https://arrow-kt.io/docs/0.10/arrow/typeclasses/unalign/ This would get you a tuple with both lists in one fold. Ior is just either with an additional both case so the mapping expected by unalignWith is straightforward. On mobile so can't give you a better example atm 😅