Module Preface_specs.Monoid

A Monoid is a type t which provides a binary associative operation combine and a neutral element (neutral). In other words, a Monoid is a Semigroup with a neutral element.


To ensure that the derived combiners work properly, a functor should respect these laws:

  1. combine (combine a b) c = combine a (combine b c) (from Semigroup)
  2. combine x neutral = combine neutral x = x

Minimal definition

module type WITH_NEUTRAL = sig ... end

A type t with a neutral element. This signature is mainly used to enrich a Semigroup with a neutral element.

module type WITH_NEUTRAL_AND_COMBINE = sig ... end

Structure anatomy


Basis operations.

module type OPERATION = sig ... end

Additional operations.

module type INFIX = sig ... end

Infix operators.

Complete API

module type API = sig ... end

The complete interface of a Monoid.

Additional references