FuncType - v0.60.3
    Preparing search index...

    Interface Traversable<A>

    Traversable typeclass for data structures that can be traversed through.

    Covariance: A is declared <out A>. Query (contains) accepts unknown — mirroring Scala's contains(elem: Any) — so an unrelated-type arg is a sound false rather than a type error. Aggregations (reduce, reduceRight) widen the accumulator via <B = A>, matching Scala's reduce[B >: A]; when called without an explicit type arg the behavior is identical to the pre-0.59 signature, so existing call sites compile unchanged.

    Implementers that previously overrode these methods with the widened shape (List, Set) can inherit from this base without a per-type override.

    interface Traversable<out A extends Type> {
        get isEmpty(): boolean;
        get size(): number;
        ap<B extends unknown>(ff: Applicative<(value: A) => B>): Applicative<B>;
        contains(value: unknown): boolean;
        flatMap<B extends unknown>(f: (value: A) => Monad<B>): Monad<B>;
        flatMapAsync<B extends unknown>(
            f: (value: A) => PromiseLike<AsyncMonad<B>>,
        ): PromiseLike<AsyncMonad<B>>;
        map<B extends unknown>(f: (value: A) => B): Functor<B>;
        reduce<B = A>(
            op: (b: Widen<A, B>, a: Widen<A, B>) => Widen<A, B>,
        ): Widen<A, B>;
        reduceRight<B = A>(
            op: (b: Widen<A, B>, a: Widen<A, B>) => Widen<A, B>,
        ): Widen<A, B>;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Accessors

    • get isEmpty(): boolean

      Returns boolean

    • get size(): number

      Returns number

    Methods

    • Parameters

      • value: unknown

      Returns boolean