Skip to main content
Module

x/fun/mod.ts>array.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 array.getMonoid
import { array } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { getMonoid } = array;

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>>