traverseListWithIndex<E, A, B> static method

IOEither<E, List<B>> traverseListWithIndex<E, A, B>(
  1. List<A> list,
  2. IOEither<E, B> f(
    1. A a,
    2. int i
    )
)

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

Same as IOEither.traverseList but passing index in the map function.

Implementation

static IOEither<E, List<B>> traverseListWithIndex<E, A, B>(
  List<A> list,
  IOEither<E, B> Function(A a, int i) f,
) =>
    IOEither<E, List<B>>(
      () => Either.sequenceList(
        IO
            .traverseListWithIndex<A, Either<E, B>>(
              list,
              (a, i) => IO(() => f(a, i).run()),
            )
            .run(),
      ),
    );