Extra v0.2.0 Monoid protocol
Monoids extend semigroups, objects with an associative binary operator, by adding the notion of an identity element.
Given the mcat operator as ⋅, monoids must satisfy:
∀ a. identity ⋅ a = a ⋅ identity = a ∀ a b c. a ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
Built-in instances
Built in instances are defined for List, Map, and Stream. For example:
iex> Monoid.mplus([1, 2], [3, 4]) [1, 2, 3, 4]
iex> Monoid.identity([1, 2, 3]) []
iex> Monoid.identity(%{foo: :bar}) %{}
Link to this section Summary
Functions
The left and right identity of mplus
The associative binary operator over objects of this monoidal category
Link to this section Types
Link to this section Functions
The left and right identity of mplus
The associative binary operator over objects of this monoidal category