import type { Magma } from './Magma' /** * `Semigroup` defines an associative binary operator `combine` on given type `A`. * `combine` must fulfill the associativity law, which states that for a binary operation `*` on type `A`: * * ``` * (a * b) * c === a * (b * c) for all a, b, c, in A * ``` * * `Semigroup` defines both an uncurried function `combine_` and a curried function * `combine` with arguments interchanged for `pipeable` application. */ export interface Semigroup extends Magma {} export function Semigroup(combine: (x: A, y: A) => A): Semigroup { return { combine_: combine, combine: (y) => (x) => combine(x, y) } }