FuncType - v0.8.85
    Preparing search index...

    Interface FunctypeBase<A, Tag>

    Base interface for all functype data structures. This provides a standard contract with core functional programming traits.

    // Implementing FunctypeBase for a custom data structure
    class MyContainer<T> implements FunctypeBase<T, "Empty" | "Full"> {
    // Implementation of all required methods...
    }
    interface FunctypeBase<A, Tag extends string = string> {
        _tag: Tag;
        get isEmpty(): boolean;
        get size(): number;
        ap<B extends unknown>(ff: Applicative<(value: A) => B>): Applicative<B>;
        contains(value: A): boolean;
        count(p: (x: A) => boolean): number;
        exists(p: (a: A) => boolean): boolean;
        find(p: (a: A) => boolean): Option<A>;
        flatMap<B extends unknown>(f: (value: A) => Monad<B>): Monad<B>;
        flatMapAsync<B extends unknown>(
            f: (value: A) => PromiseLike<AsyncMonad<B>>,
        ): PromiseLike<AsyncMonad<B>>;
        fold<B>(onEmpty: () => B, onValue: (value: A) => B): 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>;
        reduce(f: (b: A, a: A) => A): A;
        reduceRight(f: (b: A, a: A) => A): A;
        serialize(): SerializationMethods<A>;
    }

    Type Parameters

    • A

      The type of value contained in the functor

    • Tag extends string = string

      The type tag for pattern matching (e.g., "Some" | "None" for Option)

    Hierarchy (View Summary)

    Index

    Properties

    _tag: Tag

    Accessors

    • get isEmpty(): boolean

      Returns boolean

    • get size(): number

      Returns number

    Methods

    • Counts elements that satisfy the predicate. For single-value containers: returns 0 or 1 For collections: returns the count of matching elements

      Parameters

      • p: (x: A) => boolean

      Returns number

    • Tests whether any element satisfies the predicate. For single-value containers: tests the single value For collections: returns true if any element matches

      Parameters

      • p: (a: A) => boolean

      Returns boolean

    • Finds the first element that satisfies the predicate. For single-value containers: returns Some(value) if predicate matches, None otherwise For collections: returns the first matching element wrapped in Option

      Parameters

      • p: (a: A) => boolean

      Returns Option<A>

    • Pattern matches over the structure, applying specific handlers for each variant

      Type Parameters

      • B

      Parameters

      • onEmpty: () => B

        Function to apply if the structure is empty or has no value

      • onValue: (value: A) => B

        Function to apply if the structure has a value

      Returns B

      The result of applying the appropriate function

    • 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

    • Applies an effect function to each element. For single-value containers: applies to the value if present For collections: applies to each element

      Parameters

      • f: (a: A) => void

      Returns void