Table of contents


Monoid (interface)

Signature

export interface Monoid<A> extends Semigroup<A> {
  readonly empty: A
}

Added in v2.0.0

monoidAll (constant)

Boolean monoid under conjunction

Signature

export const monoidAll: Monoid<boolean> = ...

Added in v2.0.0

monoidAny (constant)

Boolean monoid under disjunction

Signature

export const monoidAny: Monoid<boolean> = ...

Added in v2.0.0

monoidProduct (constant)

Number monoid under multiplication

Signature

export const monoidProduct: Monoid<number> = ...

Added in v2.0.0

monoidString (constant)

Signature

export const monoidString: Monoid<string> = ...

Added in v2.0.0

monoidSum (constant)

Number monoid under addition

Signature

export const monoidSum: Monoid<number> = ...

Added in v2.0.0

monoidVoid (constant)

Signature

export const monoidVoid: Monoid<void> = ...

Added in v2.0.0

fold (function)

Signature

export function fold<A>(M: Monoid<A>): (as: Array<A>) => A { ... }

Added in v2.0.0

getDualMonoid (function)

Signature

export function getDualMonoid<A>(M: Monoid<A>): Monoid<A> { ... }

Added in v2.0.0

getEndomorphismMonoid (function)

Signature

export function getEndomorphismMonoid<A = never>(): Monoid<Endomorphism<A>> { ... }

Added in v2.0.0

getFunctionMonoid (function)

Signature

export function getFunctionMonoid<M>(M: Monoid<M>): <A = never>() => Monoid<(a: A) => M> { ... }

Added in v2.0.0

getJoinMonoid (function)

Signature

export function getJoinMonoid<A>(B: Bounded<A>): Monoid<A> { ... }

Added in v2.0.0

getMeetMonoid (function)

Signature

export function getMeetMonoid<A>(B: Bounded<A>): Monoid<A> { ... }

Added in v2.0.0

getStructMonoid (function)

Signature

export function getStructMonoid<O extends { [key: string]: any }>(
  monoids: { [K in keyof O]: Monoid<O[K]> }
): Monoid<O> { ... }

Added in v2.0.0

getTupleMonoid (function)

Given a tuple of monoids returns a monoid for the tuple

Signature

export function getTupleMonoid<T extends Array<Monoid<any>>>(
  ...monoids: T
): Monoid<{ [K in keyof T]: T[K] extends Semigroup<infer A> ? A : never }> { ... }

Example

import { getTupleMonoid, monoidString, monoidSum, monoidAll } from 'fp-ts/lib/Monoid'

const M1 = getTupleMonoid(monoidString, monoidSum)
assert.deepStrictEqual(M1.concat(['a', 1], ['b', 2]), ['ab', 3])

const M2 = getTupleMonoid(monoidString, monoidSum, monoidAll)
assert.deepStrictEqual(M2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])

Added in v2.0.0