template <class MonadTag>
struct monad_plus;
// Requires:
// struct mzero;
// struct mplus { template <class, class> struct apply; };
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>
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> {};
};
};
Copyright Abel Sinkovics (abel at elte dot hu) 2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt