Skip to main content
Module

x/fun/semigroup.ts>concatAll

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function concatAll
import { concatAll } from "https://deno.land/x/fun@v2.0.0-alpha.6/semigroup.ts";

Given a semigroup, create a function that will iterate through an array of values and concat them. This is not much more than Array.reduce(concat).

Examples

Example 1

import * as SG from "./semigroup.ts";
import * as N from "./number.ts";
import { pipe } from "./fn.ts";

const sumAll = SG.concatAll(N.SemigroupNumberSum);

const sum = pipe(
  [1, 30, 80, 1000, 52, 42],
  sumAll(0),
); // sum === 1205

Returns

(startWith: A) => (as: ReadonlyArray<A>) => A