language-agnosticmathcomputer-sciencemonoidsabstract-algebra

Examples of monoids/semigroups in programming


It is well-known that monoids are stunningly ubiquitous in programing. They are so ubiquitous and so useful that I, as a 'hobby project', am working on a system that is completely based on their properties (distributed data aggregation). To make the system useful I need useful monoids :)

I already know of these:

Now, let us define a quasi-property of an operation as a property that holds up to an equivalence relation. For example, list concatenation is quasi-commutative if we consider lists of equal length or with identical contents up to permutation to be equivalent.

Here are some quasi-monoids and quasi-commutative monoids and semigroups:

Which others do exist?


Solution

  • Quotient monoid is another way to form monoids (quasimonoids?): given monoid M and an equivalence relation ~ compatible with multiplication, it gives another monoid. For example:

    Quotient monoids automatically come with homomorphism M -> M/~ that is surjective.

    A "dual" construction are submonoids. They come with homomorphism A -> M that is injective.

    Yet another construction on monoids is tensor product.

    Monoids allow exponentation by squaring in O(log n) and fast parallel prefix sums computation. Also they are used in Writer monad.