package alg_structs
Module Alg_structs.MonoidSource
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 = intop = (+)unit = 0
- The integers under multiplication
type t = intop = ( * )unit = 1
- Strings under concatenation
type t = stringop = (^)unit = ""
Seed
Interface
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
Law notes the laws that should be obeyed by any instantiation of Monoid in the form of predicates that should hold true for any arguments of the appropriate type.
Constructors
Module functors for creating implementations of Monoid
make (unit : t) (op : t -> t -> t) is an implementation of Monoid over the type t with the given unit and op
of_semigroup semi unit forms an implementation of Monoid by enriching the give semigroup semi with the unit
Implementations
See Semigroup.Endo
See Semigroup.Dual