/** * A `Traversable` with an additional index. * A `TraversableWithIndex` instance must be compatible with its `Traversable` instance * * ```ts * traverse(F)(ta, f) = traverseWithIndex(F)(ta, (_, a) => f(a)) * ``` * * with its `FoldableWithIndex` instance * * ```ts * foldMapWithIndex(M)(ta, f) = traverseWithIndex(getApplicative(M))(ta, (i, a) => new Const(f(i, a))).value * ``` * * and with its `FunctorWithIndex` instance * * ```purescript * mapWithIndex(ta, f) = traverseWithIndex(identity)(ta, (i, a) => new Identity(f(i, a))).value * ``` * * @since 2.0.0 */ import { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C } from './Applicative' import { FoldableWithIndex, FoldableWithIndex1, FoldableWithIndex2, FoldableWithIndex2C } from './FoldableWithIndex' import { FunctorWithIndex, FunctorWithIndex1, FunctorWithIndex2, FunctorWithIndex2C } from './FunctorWithIndex' import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT' import { Traversable, Traversable1, Traversable2, Traversable2C } from './Traversable' /** * @since 2.0.0 */ export interface TraversableWithIndex extends FunctorWithIndex, FoldableWithIndex, Traversable { readonly traverseWithIndex: TraverseWithIndex } /** * @since 2.0.0 */ export interface TraversableWithIndex1 extends FunctorWithIndex1, FoldableWithIndex1, Traversable1 { readonly traverseWithIndex: TraverseWithIndex1 } /** * @since 2.0.0 */ export interface TraversableWithIndex2 extends FunctorWithIndex2, FoldableWithIndex2, Traversable2 { readonly traverseWithIndex: TraverseWithIndex2 } /** * @since 2.0.0 */ export interface TraversableWithIndex2C extends FunctorWithIndex2C, FoldableWithIndex2C, Traversable2C { readonly traverseWithIndex: TraverseWithIndex2C } /** * @since 2.0.0 */ export interface TraverseWithIndex { (F: Applicative3): ( ta: HKT, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative3C): ( ta: HKT, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative2): ( ta: HKT, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative2C): ( ta: HKT, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative1): (ta: HKT, f: (i: I, a: A) => Kind) => Kind> (F: Applicative): (ta: HKT, f: (i: I, a: A) => HKT) => HKT> } /** * @since 2.0.0 */ export interface TraverseWithIndex1 { (F: Applicative3): ( ta: Kind, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative3C): ( ta: Kind, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative2): ( ta: Kind, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative2C): ( ta: Kind, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative1): (ta: Kind, f: (i: I, a: A) => Kind) => Kind> (F: Applicative): (ta: Kind, f: (i: I, a: A) => HKT) => HKT> } /** * @since 2.0.0 */ export interface TraverseWithIndex2 { (F: Applicative3): ( ta: Kind2, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative2): ( ta: Kind2, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative2C): ( ta: Kind2, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative1): ( ta: Kind2, f: (i: I, a: A) => Kind ) => Kind> (F: Applicative): (ta: Kind2, f: (i: I, a: A) => HKT) => HKT> } /** * @since 2.0.0 */ export interface TraverseWithIndex2C { (F: Applicative3): ( ta: Kind2, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative3C): ( ta: Kind2, f: (i: I, a: A) => Kind3 ) => Kind3> (F: Applicative2): ( ta: Kind2, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative2C): ( ta: Kind2, f: (i: I, a: A) => Kind2 ) => Kind2> (F: Applicative1): ( ta: Kind2, f: (i: I, a: A) => Kind ) => Kind> (F: Applicative): (ta: Kind2, f: (i: I, a: A) => HKT) => HKT> } /** * @since 2.6.3 */ export interface PipeableTraverseWithIndex1 { (F: Applicative3): ( f: (i: I, a: A) => Kind3 ) => (ta: Kind) => Kind3> (F: Applicative3C): ( f: (i: I, a: A) => Kind3 ) => (ta: Kind) => Kind3> (F: Applicative2): ( f: (i: I, a: A) => Kind2 ) => (ta: Kind) => Kind2> (F: Applicative2C): ( f: (i: I, a: A) => Kind2 ) => (ta: Kind) => Kind2> (F: Applicative1): (f: (i: I, a: A) => Kind) => (ta: Kind) => Kind> (F: Applicative): (f: (i: I, a: A) => HKT) => (ta: Kind) => HKT> } /** * @since 2.6.3 */ export interface PipeableTraverseWithIndex2 { (F: Applicative3): ( f: (i: I, a: A) => Kind3 ) => (ta: Kind2) => Kind3> (F: Applicative2): ( f: (i: I, a: A) => Kind2 ) => (ta: Kind2) => Kind2> (F: Applicative2C): ( f: (i: I, a: A) => Kind2 ) => (ta: Kind2) => Kind2> (F: Applicative1): ( f: (i: I, a: A) => Kind ) => (ta: Kind2) => Kind> (F: Applicative): (f: (i: I, a: A) => HKT) => (ta: Kind2) => HKT> }