Skip to main content
Module

x/fun/monoid.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.10/monoid.ts";

Given a Monoid, 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 M from "./monoid.ts";
import * as N from "./number.ts";
import { pipe } from "./fn.ts";

const sumAll = M.concatAll(N.MonoidNumberSum);

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

Returns

(as: ReadonlyArray<A>) => A