template <class MonoidTag>
struct monoid;
  // Requires:
  //   publicly inherit from monoid_defaults<MonoidTag>
  //   struct mempty;
  //   struct mappend { template <class, class> struct apply; };

template <class MonadTag>
struct monoid_defaults
  struct mconcat
    template <class L>
    struct apply
      // unspecified


This is a typeclass for monoids. A monoid is an abstraction of a type and an associative operation (mappend) on it. The operation is required to have an identity element (mempty). Examples:

Monoids have a mconcat operation that takes a sequence of values and produces as sum value from it by repeatedly calling mappend.

For any MonoidTag, the operations are expected to meet the following requirements:

Due to the way Metamonad handles versioning, the monoid template class has to be specialised in the mpllibs::metamonad::v1 namespace.

#include <mpllibs/metamonad/monoid.hpp>


using boost::mpl;

struct plus_tag : mpllibs::metamonad::tmp_tag<plus_tag> {};

template <>
struct monoid<plus_tag> : monoid_defaults<plus_tag>
  typedef int0 mempty;
  typedef lambda_c<a, b, plus<a, b>> mappend;