Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Foldable

import type { Foldable } from "https://raw.githubusercontent.com/baetheus/fun/main/foldable.ts";

A Foldable structure has the method fold.

@example
import * as A from "./array.ts";
import { pipe } from "./fn.ts";

const numbers = [1, 2, 3, 4, 5];
const sum = pipe(
  numbers,
  A.FoldableArray.fold(
    (acc, value) => acc + value,
    0
  )
);

console.log(sum); // 15
interface Foldable <U extends Kind> extends Hold<U> {
readonly fold: <A, O>(reducer: (accumulator: O, value: A) => O, accumulator: O) => <B = never, C = never, D = unknown, E = unknown>(ua: $<U, [A, B, C], [D], [E]>) => O;
}

§Type Parameters

§
U extends Kind
[src]

§Extends

§Properties

§
readonly fold: <A, O>(reducer: (accumulator: O, value: A) => O, accumulator: O) => <B = never, C = never, D = unknown, E = unknown>(ua: $<U, [A, B, C], [D], [E]>) => O
[src]