traverseEither<B, L> method

Either<L, IList<B>> traverseEither<B, L>(
  1. Either<L, B> f(
    1. A a
    )
)

Implementation

Either<L, IList<B>> traverseEither<B, L>(Either<L, B> f(A a)) {
  Either<L, IList<B>> result = right(nil());
  var current = this;
  while(current._isCons()) {
    final gb = f(current._unsafeHead());
    result = result.fold(left, (a) => gb.fold(left, (h) => right(new Cons(h, a))));
    current = current._unsafeTail();
  }
  return result.map((l) => l.reverse());
}