← Back



interface TraversableWithIndex<T, I> extends FunctorWithIndex<T, I>, FoldableWithIndex<T, I>, Traversable2v<T> {
  readonly traverseWithIndex: TraverseWithIndex<T, I>

Added in v1.12.0 (type class)

A Traversable with an additional index. A TraversableWithIndex instance must be compatible with its Traversable instance

traverse(F)(ta, f) = traverseWithIndex(F)(ta, (_, a) => f(a))

with its FoldableWithIndex instance

foldMapWithIndex(M)(ta, f) = traverseWithIndex(getApplicative(M))(ta, (i, a) => new Const(f(i, a))).value

and with its FunctorWithIndex instance

mapWithIndex(ta, f) = traverseWithIndex(identity)(ta, (i, a) => new Identity(f(i, a))).value