Skip to main content
Module

x/fun/array.ts>getMonoid

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 getMonoid
import { getMonoid } from "https://deno.land/x/fun@v2.0.0-alpha.6/array.ts";

Create an instance of Monoid<ReadonlyArray> given a type A. This instance uses array concat and empty as the instance methods for the Monoid.

Examples

Example 1

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

const monoid = A.getMonoid<number>();

const result = pipe(
  monoid.empty(), // []
  monoid.concat([1, 2, 3]),
); // [1, 2, 3]

Type Parameters

optional
A = never

Returns

Monoid<ReadonlyArray<A>>