diff --git a/Control/Monad/Trans/Accum.hs b/Control/Monad/Trans/Accum.hs index cb06eba..9ae05f2 100644 --- a/Control/Monad/Trans/Accum.hs +++ b/Control/Monad/Trans/Accum.hs @@ -115,7 +115,7 @@ execAccum m w = snd (runAccum m w) -- and return the final value, discarding the final output. -- -- * @'evalAccum' m w = 'fst' ('runAccum' m w)@ -evalAccum :: (Monoid w) => Accum w a -> w -> a +evalAccum :: Accum w a -> w -> a evalAccum m w = fst (runAccum m w) {-# INLINE evalAccum #-} @@ -173,7 +173,7 @@ execAccumT m w = do -- history and return the final value, discarding the final output. -- -- * @'evalAccumT' m w = 'liftM' 'fst' ('runAccumT' m w)@ -evalAccumT :: (Monad m, Monoid w) => AccumT w m a -> w -> m a +evalAccumT :: (Monad m) => AccumT w m a -> w -> m a evalAccumT m w = do ~(a, _) <- runAccumT m w return a @@ -191,7 +191,7 @@ instance (Functor m) => Functor (AccumT w m) where fmap f = mapAccumT $ fmap $ \ ~(a, w) -> (f a, w) {-# INLINE fmap #-} -instance (Monoid w, Functor m, Monad m) => Applicative (AccumT w m) where +instance (Monoid w, Monad m) => Applicative (AccumT w m) where pure a = AccumT $ const $ return (a, mempty) {-# INLINE pure #-} mf <*> mv = AccumT $ \ w -> do @@ -200,13 +200,13 @@ instance (Monoid w, Functor m, Monad m) => Applicative (AccumT w m) where return (f v, w' `mappend` w'') {-# INLINE (<*>) #-} -instance (Monoid w, Functor m, MonadPlus m) => Alternative (AccumT w m) where +instance (Monoid w, MonadPlus m) => Alternative (AccumT w m) where empty = AccumT $ const mzero {-# INLINE empty #-} m <|> n = AccumT $ \ w -> runAccumT m w `mplus` runAccumT n w {-# INLINE (<|>) #-} -instance (Monoid w, Functor m, Monad m) => Monad (AccumT w m) where +instance (Monoid w, Monad m) => Monad (AccumT w m) where #if !(MIN_VERSION_base(4,8,0)) return a = AccumT $ const $ return (a, mempty) {-# INLINE return #-} @@ -227,13 +227,13 @@ instance (Monoid w, Fail.MonadFail m) => Fail.MonadFail (AccumT w m) where {-# INLINE fail #-} #endif -instance (Monoid w, Functor m, MonadPlus m) => MonadPlus (AccumT w m) where +instance (Monoid w, MonadPlus m) => MonadPlus (AccumT w m) where mzero = AccumT $ const mzero {-# INLINE mzero #-} m `mplus` n = AccumT $ \ w -> runAccumT m w `mplus` runAccumT n w {-# INLINE mplus #-} -instance (Monoid w, Functor m, MonadFix m) => MonadFix (AccumT w m) where +instance (Monoid w, MonadFix m) => MonadFix (AccumT w m) where mfix m = AccumT $ \ w -> mfix $ \ ~(a, _) -> runAccumT (m a) w {-# INLINE mfix #-} @@ -243,7 +243,7 @@ instance (Monoid w) => MonadTrans (AccumT w) where return (a, mempty) {-# INLINE lift #-} -instance (Monoid w, Functor m, MonadIO m) => MonadIO (AccumT w m) where +instance (Monoid w, MonadIO m) => MonadIO (AccumT w m) where liftIO = lift . liftIO {-# INLINE liftIO #-} diff --git a/Control/Monad/Trans/Except.hs b/Control/Monad/Trans/Except.hs index 049a0f3..51d5ca0 100644 --- a/Control/Monad/Trans/Except.hs +++ b/Control/Monad/Trans/Except.hs @@ -198,7 +198,7 @@ instance (Traversable f) => Traversable (ExceptT e f) where ExceptT <$> traverse (either (pure . Left) (fmap Right . f)) a {-# INLINE traverse #-} -instance (Functor m, Monad m) => Applicative (ExceptT e m) where +instance (Monad m) => Applicative (ExceptT e m) where pure a = ExceptT $ return (Right a) {-# INLINE pure #-} ExceptT f <*> ExceptT v = ExceptT $ do @@ -214,7 +214,7 @@ instance (Functor m, Monad m) => Applicative (ExceptT e m) where m *> k = m >>= \_ -> k {-# INLINE (*>) #-} -instance (Functor m, Monad m, Monoid e) => Alternative (ExceptT e m) where +instance (Monad m, Monoid e) => Alternative (ExceptT e m) where empty = ExceptT $ return (Left mempty) {-# INLINE empty #-} ExceptT mx <|> ExceptT my = ExceptT $ do diff --git a/Control/Monad/Trans/Maybe.hs b/Control/Monad/Trans/Maybe.hs index cab161d..52ee337 100644 --- a/Control/Monad/Trans/Maybe.hs +++ b/Control/Monad/Trans/Maybe.hs @@ -146,7 +146,7 @@ instance (Traversable f) => Traversable (MaybeT f) where traverse f (MaybeT a) = MaybeT <$> traverse (traverse f) a {-# INLINE traverse #-} -instance (Functor m, Monad m) => Applicative (MaybeT m) where +instance (Monad m) => Applicative (MaybeT m) where pure = MaybeT . return . Just {-# INLINE pure #-} mf <*> mx = MaybeT $ do @@ -162,7 +162,7 @@ instance (Functor m, Monad m) => Applicative (MaybeT m) where m *> k = m >>= \_ -> k {-# INLINE (*>) #-} -instance (Functor m, Monad m) => Alternative (MaybeT m) where +instance (Monad m) => Alternative (MaybeT m) where empty = MaybeT (return Nothing) {-# INLINE empty #-} x <|> y = MaybeT $ do diff --git a/Control/Monad/Trans/RWS/CPS.hs b/Control/Monad/Trans/RWS/CPS.hs index f089db6..4a26425 100644 --- a/Control/Monad/Trans/RWS/CPS.hs +++ b/Control/Monad/Trans/RWS/CPS.hs @@ -214,7 +214,7 @@ instance (Functor m) => Functor (RWST r w s m) where fmap f m = RWST $ \ r s w -> (\ (a, s', w') -> (f a, s', w')) <$> unRWST m r s w {-# INLINE fmap #-} -instance (Functor m, Monad m) => Applicative (RWST r w s m) where +instance (Monad m) => Applicative (RWST r w s m) where pure a = RWST $ \ _ s w -> return (a, s, w) {-# INLINE pure #-} @@ -224,7 +224,7 @@ instance (Functor m, Monad m) => Applicative (RWST r w s m) where return (f x, s'', w'') {-# INLINE (<*>) #-} -instance (Functor m, MonadPlus m) => Alternative (RWST r w s m) where +instance (MonadPlus m) => Alternative (RWST r w s m) where empty = RWST $ \ _ _ _ -> mzero {-# INLINE empty #-} @@ -253,7 +253,7 @@ instance (Fail.MonadFail m) => Fail.MonadFail (RWST r w s m) where {-# INLINE fail #-} #endif -instance (Functor m, MonadPlus m) => MonadPlus (RWST r w s m) where +instance (MonadPlus m) => MonadPlus (RWST r w s m) where mzero = empty {-# INLINE mzero #-} mplus = (<|>) diff --git a/Control/Monad/Trans/RWS/Lazy.hs b/Control/Monad/Trans/RWS/Lazy.hs index 5fd8f2d..0f1c750 100644 --- a/Control/Monad/Trans/RWS/Lazy.hs +++ b/Control/Monad/Trans/RWS/Lazy.hs @@ -190,7 +190,7 @@ instance (Functor m) => Functor (RWST r w s m) where fmap (\ ~(a, s', w) -> (f a, s', w)) $ runRWST m r s {-# INLINE fmap #-} -instance (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) where +instance (Monoid w, Monad m) => Applicative (RWST r w s m) where pure a = RWST $ \ _ s -> return (a, s, mempty) {-# INLINE pure #-} RWST mf <*> RWST mx = RWST $ \ r s -> do @@ -199,7 +199,7 @@ instance (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) where return (f x, s'', w `mappend` w') {-# INLINE (<*>) #-} -instance (Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m) where +instance (Monoid w, MonadPlus m) => Alternative (RWST r w s m) where empty = RWST $ \ _ _ -> mzero {-# INLINE empty #-} RWST m <|> RWST n = RWST $ \ r s -> m r s `mplus` n r s diff --git a/Control/Monad/Trans/RWS/Strict.hs b/Control/Monad/Trans/RWS/Strict.hs index a7f66db..e43fad8 100644 --- a/Control/Monad/Trans/RWS/Strict.hs +++ b/Control/Monad/Trans/RWS/Strict.hs @@ -194,7 +194,7 @@ instance (Functor m) => Functor (RWST r w s m) where fmap (\ (a, s', w) -> (f a, s', w)) $ runRWST m r s {-# INLINE fmap #-} -instance (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) where +instance (Monoid w, Monad m) => Applicative (RWST r w s m) where pure a = RWST $ \ _ s -> return (a, s, mempty) {-# INLINE pure #-} RWST mf <*> RWST mx = RWST $ \ r s -> do @@ -203,7 +203,7 @@ instance (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) where return (f x, s'', w `mappend` w') {-# INLINE (<*>) #-} -instance (Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m) where +instance (Monoid w, MonadPlus m) => Alternative (RWST r w s m) where empty = RWST $ \ _ _ -> mzero {-# INLINE empty #-} RWST m <|> RWST n = RWST $ \ r s -> m r s `mplus` n r s diff --git a/Control/Monad/Trans/Select.hs b/Control/Monad/Trans/Select.hs index 29eb6c4..8feff89 100644 --- a/Control/Monad/Trans/Select.hs +++ b/Control/Monad/Trans/Select.hs @@ -106,7 +106,7 @@ instance (Functor m) => Functor (SelectT r m) where fmap f (SelectT g) = SelectT (fmap f . g . (. f)) {-# INLINE fmap #-} -instance (Functor m, Monad m) => Applicative (SelectT r m) where +instance (Monad m) => Applicative (SelectT r m) where pure = lift . return {-# INLINE pure #-} SelectT gf <*> SelectT gx = SelectT $ \ k -> do @@ -117,7 +117,7 @@ instance (Functor m, Monad m) => Applicative (SelectT r m) where m *> k = m >>= \_ -> k {-# INLINE (*>) #-} -instance (Functor m, MonadPlus m) => Alternative (SelectT r m) where +instance (MonadPlus m) => Alternative (SelectT r m) where empty = mzero {-# INLINE empty #-} (<|>) = mplus diff --git a/Control/Monad/Trans/State/Lazy.hs b/Control/Monad/Trans/State/Lazy.hs index 67fd597..e8f7e55 100644 --- a/Control/Monad/Trans/State/Lazy.hs +++ b/Control/Monad/Trans/State/Lazy.hs @@ -213,7 +213,7 @@ instance (Functor m) => Functor (StateT s m) where fmap (\ ~(a, s') -> (f a, s')) $ runStateT m s {-# INLINE fmap #-} -instance (Functor m, Monad m) => Applicative (StateT s m) where +instance (Monad m) => Applicative (StateT s m) where pure a = StateT $ \ s -> return (a, s) {-# INLINE pure #-} StateT mf <*> StateT mx = StateT $ \ s -> do @@ -224,7 +224,7 @@ instance (Functor m, Monad m) => Applicative (StateT s m) where m *> k = m >>= \_ -> k {-# INLINE (*>) #-} -instance (Functor m, MonadPlus m) => Alternative (StateT s m) where +instance (MonadPlus m) => Alternative (StateT s m) where empty = StateT $ \ _ -> mzero {-# INLINE empty #-} StateT m <|> StateT n = StateT $ \ s -> m s `mplus` n s diff --git a/Control/Monad/Trans/State/Strict.hs b/Control/Monad/Trans/State/Strict.hs index 040c871..64016da 100644 --- a/Control/Monad/Trans/State/Strict.hs +++ b/Control/Monad/Trans/State/Strict.hs @@ -206,7 +206,7 @@ instance (Functor m) => Functor (StateT s m) where fmap (\ (a, s') -> (f a, s')) $ runStateT m s {-# INLINE fmap #-} -instance (Functor m, Monad m) => Applicative (StateT s m) where +instance (Monad m) => Applicative (StateT s m) where pure a = StateT $ \ s -> return (a, s) {-# INLINE pure #-} StateT mf <*> StateT mx = StateT $ \ s -> do @@ -217,7 +217,7 @@ instance (Functor m, Monad m) => Applicative (StateT s m) where m *> k = m >>= \_ -> k {-# INLINE (*>) #-} -instance (Functor m, MonadPlus m) => Alternative (StateT s m) where +instance (MonadPlus m) => Alternative (StateT s m) where empty = StateT $ \ _ -> mzero {-# INLINE empty #-} StateT m <|> StateT n = StateT $ \ s -> m s `mplus` n s diff --git a/Control/Monad/Trans/Writer/CPS.hs b/Control/Monad/Trans/Writer/CPS.hs index 3b63c49..d04d246 100644 --- a/Control/Monad/Trans/Writer/CPS.hs +++ b/Control/Monad/Trans/Writer/CPS.hs @@ -169,7 +169,7 @@ instance (Functor m) => Functor (WriterT w m) where fmap f m = WriterT $ \ w -> (\ (a, w') -> (f a, w')) <$> unWriterT m w {-# INLINE fmap #-} -instance (Functor m, Monad m) => Applicative (WriterT w m) where +instance (Monad m) => Applicative (WriterT w m) where pure a = WriterT $ \ w -> return (a, w) {-# INLINE pure #-} @@ -179,7 +179,7 @@ instance (Functor m, Monad m) => Applicative (WriterT w m) where return (f x, w'') {-# INLINE (<*>) #-} -instance (Functor m, MonadPlus m) => Alternative (WriterT w m) where +instance (MonadPlus m) => Alternative (WriterT w m) where empty = WriterT $ const mzero {-# INLINE empty #-} @@ -208,7 +208,7 @@ instance (Fail.MonadFail m) => Fail.MonadFail (WriterT w m) where {-# INLINE fail #-} #endif -instance (Functor m, MonadPlus m) => MonadPlus (WriterT w m) where +instance (MonadPlus m) => MonadPlus (WriterT w m) where mzero = empty {-# INLINE mzero #-} mplus = (<|>) diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..0111f91 --- /dev/null +++ b/cabal.project @@ -0,0 +1,6 @@ + +packages: . + +program-options + ghc-options: + -Wall -Wredundant-constraints -Werror