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

fold

import { fold } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/free.ts";

Fold over a Free structure to produce a single value.

@example
import { fold, node, link } from "./free.ts";
import { pipe } from "./fn.ts";

const free = link(node(1), node(2));
const sum = pipe(
  free,
  fold(
    (value, acc) => value + acc,
    0
  )
);

console.log(sum); // 3
function fold<A, O>(foldr: (value: A, accumulator: O) => O, initial: O): (ua: Free<A>) => O;
§
fold<A, O>(foldr: (value: A, accumulator: O) => O, initial: O): (ua: Free<A>) => O
[src]

§Type Parameters

§Parameters

§
foldr: (value: A, accumulator: O) => O
[src]
§
initial: O
[src]

§Return Type

§
(ua: Free<A>) => O
[src]