#if __GLASGOW_HASKELL__ >= 702
#endif
module Data.Semigroup.MonadPlus
( MonadSum(..)
) where
import Control.Monad (MonadPlus(..))
#if __GLASGOW_HASKELL__ < 710
import Control.Applicative (Applicative(..),Alternative(..))
import Data.Monoid (Monoid(..))
#else
import Control.Applicative (Alternative(..))
#endif
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