monad_plus

Synopsis

template <class MonadTag>
struct monad_plus;
  // Requires:
  //   struct mzero;
  //   struct mplus { template <class, class> struct apply; };

Description

This is a typeclass for monad pluses. A monad plus represents a monad that satisfies the expectations of a monoid. The indentity value is called mzero, the operation is called mplus.

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

#include <mpllibs/metamonad/monad_plus.hpp>

Example

using boost::mpl;

struct list_tag;

template <>
struct monad_plus<list_tag>
{
  typedef list<> mzero;
  
  struct mplus
  {
    template <class A, class B>
    struct apply : insert_range<A, typename end<A>::type, B> {};
  };
};

[up]