Chuong
09/13/2024, 8:56 AMEitherA, X where A are typed errors and X varies. I want to accumulate the errors and zip up the `X`'s. I can use zipOrAccumulate for validations, but I don't need to validate the Either s, they are already validated.Alejandro Serrano.Mena
09/13/2024, 9:09 AMzipOrAccumulate(
{ firstThing.bind() },
{ secondThing.bind() },
...,
::Pair // or ::Triple, ::Tuple4, ...
}phldavies
09/13/2024, 10:29 AMinline fun A, X, R Iterable<EitherA, X>.foldOrAccumulate(initial: R, operation: (acc: R, X) -> R): EitherNelA, R =
either { flattenOrAccumulate().bind().fold(initial, operation) }
or just
Iterable<EitherError, A>.flattenOrAccumulate(): Either<NonEmptyListError, ListA>phldavies
09/13/2024, 10:32 AMfoldOrAccumulate could probably be implemented that avoids mapping to an intermediate listChuong
09/13/2024, 2:21 PM