#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
#endif
module Data.Semigroup.Alternative
( Alternate(..)
) where
import Control.Applicative
import Data.Monoid (Monoid(..))
import Data.Semigroup (Semigroup(..))
import Data.Semigroup.Reducer (Reducer(..))
newtype Alternate f a = Alternate { getAlternate :: f a }
deriving (Functor,Applicative,Alternative)
instance Alternative f => Semigroup (Alternate f a) where
Alternate a <> Alternate b = Alternate (a <|> b)
instance Alternative f => Monoid (Alternate f a) where
mempty = empty
Alternate a `mappend` Alternate b = Alternate (a <|> b)
instance Alternative f => Reducer (f a) (Alternate f a) where
unit = Alternate