jean
05/13/2024, 7:57 AMmapOrAccumulate
and parMapOrAccumulate
that fails at the first “left” rather than accumulating it? I’m trying to map a list of object to another type and wish to either get a “left” error at the first fail or get the whole new list.jean
05/13/2024, 7:59 AMobjects.mapOrAccumulate { it.toOtherType().bind() }
.mapLeft { it.first() }
It’s fine enough but it might be an function in the library doing that already?Emil Kantis
05/13/2024, 9:16 AMeither { objects.map { it.toOtherType().bind() } }?
Alejandro Serrano.Mena
05/13/2024, 9:23 AMmap
., foreach
, ...) already works in a left-biased way, so you don't need special operators for them. You only need to use OrAccumulate
versions when you want processing to continue after the first errorjean
05/13/2024, 10:45 AMmap
I end up with a List<Either<Error, OtherType>>
rather than a Either<Error, List<OtherType>>
. Wasn’t there a traverse()
method to convert a list of either to a either of list actually?Alejandro Serrano.Mena
05/13/2024, 12:02 PMmap
inside an either
context, as mentioned by @Emil Kantis abovejean
05/13/2024, 12:34 PMsimon.vergauwen
05/14/2024, 7:41 AMtraverse
in the future. I don't think they'll go as far as to also support parTraverse
, etc.
This also points to the reason for the DSL, it doesn't require any of these APIs and thus the regular APIs "just work".
Additionally, after working with it a lot we felt it consistently resulted in less code than before.