Skip to main content
Module

x/fun/semigroup.ts>Semigroup

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

A Semigroup is an algebra with a notion of concatenation. This means that it's used to merge two Ts into one T. The only rule that this merging must follow is that if you merge A, B, and C, that it doesn't matter if you start by merging A and B or start by merging B and C. There are many ways to merge values that follow these rules. A simple example is addition for numbers. It doesn't matter if you add (A + B) + C or if you add A + (B + C). The resulting sum will be the same. Thus, (number, +) can be used to make a Semigroup (see SemigroupNumberSum for this exact instance).

An instance of concat must obey the following laws:

  1. Associativity: pipe(a, concat(b), concat(c)) === pipe(a, concat(pipe(b, concat(c))))

The original type came from static-land

Properties

readonly
concat: (right: D) => (left: D) => D