traverse<L, R1, R2> function

Either<L, IList<R2>> Function(Iterable<R1>) traverse<L, R1, R2>(
  1. Either<L, R2> f(
    1. R1 a
    )
)

Transform an iterable of Either, into an Either containing an IList of the results.

Implementation

Either<L, IList<R2>> Function(Iterable<R1>) traverse<L, R1, R2>(
  Either<L, R2> Function(R1 a) f,
) =>
    (as) => as.fold(
          right(IList()),
          (acc, a) => acc._fold(
            (_) => acc,
            (bs) => f(a)._fold(
              (l) => left(l),
              (b) => right(bs.add(b)),
            ),
          ),
        );