From c9430031460a7c89038dc5e24796b69f3568b61e Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sun, 22 Nov 2015 22:12:17 +0100 Subject: [PATCH] canonical-AMP-warning avoidance --- src/Control/Comonad/Cofree.hs | 4 ++-- src/Control/Comonad/Trans/Cofree.hs | 2 ++ src/Control/Monad/Free.hs | 2 +- src/Control/Monad/Free/Church.hs | 2 +- src/Control/Monad/Trans/Free.hs | 2 +- src/Control/Monad/Trans/Iter.hs | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Control/Comonad/Cofree.hs b/src/Control/Comonad/Cofree.hs index 7718879..ea33bdd 100644 --- a/src/Control/Comonad/Cofree.hs +++ b/src/Control/Comonad/Cofree.hs @@ -157,7 +157,7 @@ instance ComonadTrans Cofree where {-# INLINE lower #-} instance Alternative f => Monad (Cofree f) where - return x = x :< empty + return = pure {-# INLINE return #-} (a :< m) >>= k = case k a of b :< n -> b :< (n <|> fmap (>>= k) m) @@ -188,7 +188,7 @@ instance ComonadApply f => ComonadApply (Cofree f) where {-# INLINE (@>) #-} instance Alternative f => Applicative (Cofree f) where - pure = return + pure x = x :< empty {-# INLINE pure #-} (<*>) = ap {-# INLINE (<*>) #-} diff --git a/src/Control/Comonad/Trans/Cofree.hs b/src/Control/Comonad/Trans/Cofree.hs index 13aef41..9dd63a7 100644 --- a/src/Control/Comonad/Trans/Cofree.hs +++ b/src/Control/Comonad/Trans/Cofree.hs @@ -168,8 +168,10 @@ instance Ord (w (CofreeF f a (CofreeT f w a))) => Ord (CofreeT f w a) where compare (CofreeT a) (CofreeT b) = compare a b instance (Alternative f, Monad w) => Monad (CofreeT f w) where +#if __GLASGOW_HASKELL__ < 710 return = CofreeT . return . (:< empty) {-# INLINE return #-} +#endif CofreeT cx >>= f = CofreeT $ do a :< m <- cx b :< n <- runCofreeT $ f a diff --git a/src/Control/Monad/Free.hs b/src/Control/Monad/Free.hs index 292b4c5..99c1137 100644 --- a/src/Control/Monad/Free.hs +++ b/src/Control/Monad/Free.hs @@ -187,7 +187,7 @@ instance Functor f => Bind (Free f) where Free m >>- f = Free ((>>- f) <$> m) instance Functor f => Monad (Free f) where - return = Pure + return = pure {-# INLINE return #-} Pure a >>= f = f a Free m >>= f = Free ((>>= f) <$> m) diff --git a/src/Control/Monad/Free/Church.hs b/src/Control/Monad/Free/Church.hs index 7558f7a..0c86b57 100644 --- a/src/Control/Monad/Free/Church.hs +++ b/src/Control/Monad/Free/Church.hs @@ -110,7 +110,7 @@ instance Bind (F f) where (>>-) = (>>=) instance Monad (F f) where - return a = F (\kp _ -> kp a) + return = pure F m >>= f = F (\kp kf -> m (\a -> runF (f a) kp kf) kf) instance MonadFix (F f) where diff --git a/src/Control/Monad/Trans/Free.hs b/src/Control/Monad/Trans/Free.hs index 794936f..6fefff2 100644 --- a/src/Control/Monad/Trans/Free.hs +++ b/src/Control/Monad/Trans/Free.hs @@ -224,7 +224,7 @@ instance (Functor f, Monad m) => Bind (FreeT f m) where instance (Functor f, Monad m) => Monad (FreeT f m) where fail e = FreeT (fail e) - return a = FreeT (return (Pure a)) + return = pure {-# INLINE return #-} FreeT m >>= f = FreeT $ m >>= \v -> case v of Pure a -> runFreeT (f a) diff --git a/src/Control/Monad/Trans/Iter.hs b/src/Control/Monad/Trans/Iter.hs index 256d819..c4ab6db 100644 --- a/src/Control/Monad/Trans/Iter.hs +++ b/src/Control/Monad/Trans/Iter.hs @@ -172,7 +172,7 @@ instance Monad m => Applicative (IterT m) where {-# INLINE (<*>) #-} instance Monad m => Monad (IterT m) where - return = IterT . return . Left + return = pure {-# INLINE return #-} IterT m >>= k = IterT $ m >>= either (runIterT . k) (return . Right . (>>= k)) {-# INLINE (>>=) #-}