Module Alg_structs.Monoid
An interface for a type with a binary, associative operator over it and a privileged unit
value.
A Monoid is a Semigroup enriched an identity element, called unit.
Some well known monoids are
- The integers under addition
type t = int
op = (+)
unit = 0
- The integers under multiplication
type t = int
op = ( * )
unit = 1
- Strings under concatenation
type t = string
op = (^)
unit = ""
Seed
Interface
module type S = sig ... end
A monoid is a set of objects with an associative binary operation over it and a privileged
unit
element that acts as an identity.
Laws
Constructors
Module functors for creating implementations of Monoid
module Make : functor (Seed : Seed) -> S with type t = Seed.t
Make S
is a implementation of Monoid grown from the implementation of theSeed
.
val make : 'a -> ('a -> 'a -> 'a) -> (module S with type t = 'a)
make (unit : t) (op : t -> t -> t)
is an implementation of Monoid over the typet
with the givenunit
andop
val of_semigroup : (module Semigroup.S with type t = 'a) -> 'a -> (module S with type t = 'a)
of_semigroup semi unit
forms an implementation of Monoid by enriching the give semigroupsemi
with theunit
Implementations
module Bool : sig ... end
Monoids over
bool
module Int : sig ... end
Monoids over
int
module Option : sig ... end
Semigroups over option types
module Endo : sig ... end
See
Semigroup.Endo
module Dual : sig ... end
See
Semigroup.Dual