Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/monoid.ts

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
import * as fun from "https://deno.land/x/fun@v.2.0.0-alpha.11/monoid.ts";

Functions

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

Create a dual Monoid from an existing monoid. This effectively switches the order of application of the original Monoid.

Create a monoid that works like Array.join, inserting middle between every two values that are concatenated. This can have some interesting results.

Create a struct Monoid from an struct of Monoids.

Create a tuple Monoid from an array of Monoids.

Interfaces

A Monoid is an algebra with a notion of emptiness. In addition to this it extends the algebra of a Semigroup. This means that an instance of Monoid has the methods empty and concat.

Type Aliases

A type for Monoid over any, useful as an extension target for functions that take any Monoid and do not need to extract the type.

A type level extractor, used to pull the inner type from a Monoid.