package alg_structs

  1. Overview
  2. Docs

An interface for a type with a binary, associative operator over it.

"A semigroup is an algebraic structure consisting of a set together with an associative binary operation" (wikipedia).

"The term 'semigroup' is standard, but semi-monoid would be more systematic." ncatlab

Modules that implement the semigroup interface are a structural subtype of the better known Monoids interface. Semigroups are differentiated from Monoids by the absence of a unit (or identity) element. in their specification.

Seed

module type Seed = sig ... end

The Seed needed to generate an implementation of Semigroup for the type t.

module type Seed1 = sig ... end

As Seed but for parameteric types of one variable

Interface

module type S = sig ... end

A semigroup is a set of objects with an associative binary operation over it

module type S1 = sig ... end

Laws

module Law (S : S) : sig ... end

Law notes the laws that should be obeyed by any instantiation of Semigroup in the form of predicates that should be true for any arguments of the appropriate type.

Constructors

Functions and module functors for creating implementations of Semigroups

module Make (S : Seed) : S with type t = S.t

Make (S) is an implementation of Semigroup generated from the Seed.

val make : ('a -> 'a -> 'a) -> (module S with type t = 'a)

make op is an implementation of Semigroup generated from the operation op.

Implementations

module Bool : sig ... end

Semigroups over bool

module Int : sig ... end

Semigroups over int

module Option : sig ... end

Semigroups over option types

module Endo : sig ... end

Endo is a semigroup where the operator is the composition of functions with input and output of the same type.

module Dual : sig ... end

Dual allows constructing the dual semigroup for a given semigroup. I.e., a semigroup with the arguments of it's operator reversed.

OCaml

Innovation. Community. Security.