UNPKG

@jsoldi/hkt

Version:

Higher kinded types for typescript and a few utility monads.

18 lines 757 B
import { monoid } from "../classes/monoid.js"; import { semiring } from "../classes/semiring.js"; /** The monoid for strings having the empty string as the identity element and string concatenation as the binary operation. */ export const string = monoid({ empty: () => "", append: (a, b) => a + b }); /** The number semiring for arithmetic addition and multiplication. */ export const num = semiring({ sum: monoid.concrete(0, (a, b) => a + b), mult: monoid.concrete(1, (a, b) => a * b) }); /** The boolean semiring having OR as addition and AND as multiplication. */ export const bool = semiring({ sum: monoid.concrete(false, (a, b) => a || b), mult: monoid.concrete(true, (a, b) => a && b) }); //# sourceMappingURL=primitive.js.map