#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
#endif
module Data.Semigroup.MonadPlus
( MonadSum(..)
) where
import Control.Monad (MonadPlus(..))
import Control.Applicative (Applicative(..),Alternative(..))
import Data.Monoid (Monoid(..))
import Data.Semigroup (Semigroup(..))
import Data.Semigroup.Reducer (Reducer(..))
newtype MonadSum f a = MonadSum { getMonadSum :: f a }
deriving (Functor,Applicative,Alternative,Monad,MonadPlus)
instance MonadPlus f => Semigroup (MonadSum f a) where
MonadSum a <> MonadSum b = MonadSum (mplus a b)
instance MonadPlus f => Monoid (MonadSum f a) where
mempty = mzero
MonadSum a `mappend` MonadSum b = MonadSum (mplus a b)
instance MonadPlus f => Reducer (f a) (MonadSum f a) where
unit = MonadSum