traverseList<E, A, B> static method

Either<E, List<B>> traverseList<E, A, B>(
  1. List<A> list,
  2. Either<E, B> f(
    1. A a
    )
)

Map each element in the list to an Either using the function f, and collect the result in an Either<E, List<B>>.

If any mapped element of the list is Left, then the final result will be Left.

Same as Either.traverseListWithIndex but without index in the map function.

Implementation

static Either<E, List<B>> traverseList<E, A, B>(
  List<A> list,
  Either<E, B> Function(A a) f,
) =>
    traverseListWithIndex<E, A, B>(list, (a, _) => f(a));