FuncType - v0.8.85
    Preparing search index...

    Interface Foldable<A>

    Foldable type class represents data structures that can be folded to a summary value.

    interface Foldable<A> {
        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;
    }

    Type Parameters

    • A

      The type of elements in the data structure

    Hierarchy (View Summary)

    Index

    Methods

    • 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