package alg_structs

  1. Overview
  2. Docs

Make S is a implementation of Monoid grown from the implementation of the Seed.

Parameters

module Seed : Seed

Signature

include Semigroup.S with type t = Seed.t
include Semigroup.Seed with type t = Seed.t
type t = Seed.t

The principle (and sole) type.

We can think of this set-theoretically as the carrier set of the algebraic structure or category-theoretically as the single object in the category, with each element being a morphism t -> t.

val op : t -> t -> t

op x y is an associative operation over all elements x and y of type t. Category-theoretically, this is the composition of morphisms.

val (*) : t -> t -> t

The infix version of op.

val concat : t NonEmptyList.t -> t

concat xs is the concatenation of all elements of xs into a single value using op.

This is equivalent to List.fold_right op (NonEmptyList.tl xs) (NonEmptyList.hd xs).

val unit : t

unit is the identity element in the monoid over t.

Every implementation must ensure that for any x : t, unit is the identity element under op, thus that the equation (x * unit) = (unit * x) = x holds.

val mconcat : t list -> t

mconcat xs is the concatenation of all elements in xs into a single value, derived by use of op.

This is equivalent to List.fold_right op xs unit.

The initial m marks this as monoidal concatenation rather than the concat function inherited from the underlying Semigroup. Since mconcat can use the unit to prime the fold, it can work over a normal list, in contrast to concat.

OCaml

Innovation. Community. Security.