Monoid

public protocol Monoid

The protocol of monoids (types with an associative binary operation that has an identity).

Instances should satisfy the following laws:

x.mappend(.mempty) = x
T.mempty.mappend(x) = x
x.mappend(y.mappend(z)) = x.mappend(y).mappend(z)
[x, y, z].mconcat() = [x, y, z].reduce(T.mempty, { $0.mappend($1) }
  • Identity of mappend(_:).

    Declaration

    Swift

    static var mempty: Self { get }
  • An associative operation.

    Declaration

    Swift

    func mappend(_ monoid: Self) -> Self