FuncType - v0.60.3
    Preparing search index...

    Interface FunctypeSum<A, Tag>

    Base interface for sum-type containers (Either, Try, etc.) that are NOT iterables.

    Unlike FunctypeBase, this base deliberately excludes Traversable — which bundles reduce / reduceRight / size / isEmpty. Those methods force A-invariance on their containers (signature (f: (A, A) => A) => A puts A in both contravariant and covariant positions) and have no semantic meaning for disjoint-union types where the "success" branch is 0-or-1, not a collection.

    Sum types that extend FunctypeSum can be declared covariant in their type parameter (interface Foo<out A>) without structural check failures. This mirrors Scala's model: Either[+L, +R] and Try[+T] do not extend Iterable; only Option[+A] extends the lighter IterableOnce[+A].

    Only the covariance-safe subset of ContainerOps is included inline: contains, exists, and forEach all place A only in contravariant (callback input) position. find (returns Option<A>) and count are intentionally omitted — if a sum type needs them it can declare them directly.

    interface FunctypeSum<A extends Type, Tag extends string = string> {
        _tag: Tag;
        "[toStringTag]": string;
        ap<B extends unknown>(ff: Applicative<(value: A) => B>): Applicative<B>;
        contains(value: A): boolean;
        exists(p: (a: A) => boolean): 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>>;
        foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
        foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
        forEach(f: (a: A) => void): void;
        map<B extends unknown>(f: (value: A) => B): Functor<B>;
        serialize(): SerializationMethods<A>;
    }

    Type Parameters

    • A extends Type

      the type of the "success" branch value

    • Tag extends string = string

      the discriminant tag (e.g., "Left" | "Right", "Success" | "Failure")

    Hierarchy (View Summary)

    Index

    Properties

    _tag: Tag
    "[toStringTag]": string

    Methods

    • Parameters

      • value: A

      Returns boolean

    • Parameters

      • p: (a: A) => boolean

      Returns boolean

    • Left-associative fold using the provided zero value and operation

      Type Parameters

      • B

      Parameters

      • z: B

        Zero/identity value

      Returns (op: (b: B, a: A) => B) => B

      A function that takes an operation to apply

    • Right-associative fold using the provided zero value and operation

      Type Parameters

      • B

      Parameters

      • z: B

        Zero/identity value

      Returns (op: (a: A, b: B) => B) => B

      A function that takes an operation to apply

    • Parameters

      • f: (a: A) => void

      Returns void