Interface Monoid<M>

  • Type Parameters:
    M - the type of values

    public interface Monoid<M>
    Interface representing monoids. A monoid consists of
    • a set of values represented by the generic type M,
    • a identity value provided by method identity(),
    • a binary combiner function represented by method combine,
    Author:
    Herbert Praehofer
    • Method Detail

      • identity

        M identity()
        Returns the identity value.
        Returns:
        the identity value
      • combine

        M combine​(M a,
                  M b)
        Combines two values of the monoid and returns a combined value.
        Parameters:
        a - the first value
        b - the second value
        Returns:
        the combined value
      • of

        static <M> Monoid<M> of​(M idty,
                                BinaryOperator<M> combiner)
        Constructs a monoid from an identity value and an binary operator.
        Type Parameters:
        M - the type of value
        Parameters:
        idty - the identity value
        combiner - the combiner function
        Returns:
        the monoid object