diff options
Diffstat (limited to 'libraries/base/Data')
-rw-r--r-- | libraries/base/Data/Complex.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Either.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Functor/Identity.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/List/NonEmpty.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Monoid.hs | 3 | ||||
-rw-r--r-- | libraries/base/Data/Proxy.hs | 2 | ||||
-rw-r--r-- | libraries/base/Data/Semigroup.hs | 21 | ||||
-rw-r--r-- | libraries/base/Data/Traversable.hs | 4 | ||||
-rw-r--r-- | libraries/base/Data/Version.hs | 9 |
9 files changed, 15 insertions, 28 deletions
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs index 09314f163e..31550d5ac7 100644 --- a/libraries/base/Data/Complex.hs +++ b/libraries/base/Data/Complex.hs @@ -213,5 +213,4 @@ instance Applicative Complex where f :+ g <*> a :+ b = f a :+ g b instance Monad Complex where - return a = a :+ a a :+ b >>= f = realPart (f a) :+ imagPart (f b) diff --git a/libraries/base/Data/Either.hs b/libraries/base/Data/Either.hs index d727e5219d..50e95824c8 100644 --- a/libraries/base/Data/Either.hs +++ b/libraries/base/Data/Either.hs @@ -134,7 +134,6 @@ instance Applicative (Either e) where Right f <*> r = fmap f r instance Monad (Either e) where - return = Right Left l >>= _ = Left l Right r >>= k = k r diff --git a/libraries/base/Data/Functor/Identity.hs b/libraries/base/Data/Functor/Identity.hs index 9f7ae24e66..46fb66650c 100644 --- a/libraries/base/Data/Functor/Identity.hs +++ b/libraries/base/Data/Functor/Identity.hs @@ -88,7 +88,6 @@ instance Applicative Identity where (<*>) = coerce instance Monad Identity where - return = Identity m >>= k = k (runIdentity m) instance MonadFix Identity where diff --git a/libraries/base/Data/List/NonEmpty.hs b/libraries/base/Data/List/NonEmpty.hs index 6698a0ba58..d8bad07c7b 100644 --- a/libraries/base/Data/List/NonEmpty.hs +++ b/libraries/base/Data/List/NonEmpty.hs @@ -189,7 +189,6 @@ instance Applicative NonEmpty where (<*>) = ap instance Monad NonEmpty where - return a = a :| [] ~(a :| as) >>= f = b :| (bs ++ bs') where b :| bs = f a bs' = as >>= toList . f diff --git a/libraries/base/Data/Monoid.hs b/libraries/base/Data/Monoid.hs index c5a4d8bdf9..eff3836396 100644 --- a/libraries/base/Data/Monoid.hs +++ b/libraries/base/Data/Monoid.hs @@ -82,7 +82,6 @@ instance Applicative Dual where (<*>) = coerce instance Monad Dual where - return = Dual m >>= k = k (getDual m) -- | The monoid of endomorphisms under composition. @@ -126,7 +125,6 @@ instance Applicative Sum where (<*>) = coerce instance Monad Sum where - return = Sum m >>= k = k (getSum m) -- | Monoid under multiplication. @@ -146,7 +144,6 @@ instance Applicative Product where (<*>) = coerce instance Monad Product where - return = Product m >>= k = k (getProduct m) -- $MaybeExamples diff --git a/libraries/base/Data/Proxy.hs b/libraries/base/Data/Proxy.hs index a9146214c0..2dad8e4e78 100644 --- a/libraries/base/Data/Proxy.hs +++ b/libraries/base/Data/Proxy.hs @@ -90,8 +90,6 @@ instance Applicative Proxy where {-# INLINE (<*>) #-} instance Monad Proxy where - return _ = Proxy - {-# INLINE return #-} _ >>= _ = Proxy {-# INLINE (>>=) #-} diff --git a/libraries/base/Data/Semigroup.hs b/libraries/base/Data/Semigroup.hs index 661e513cba..f3f9f0b326 100644 --- a/libraries/base/Data/Semigroup.hs +++ b/libraries/base/Data/Semigroup.hs @@ -332,8 +332,7 @@ instance Applicative Min where Min f <*> Min x = Min (f x) instance Monad Min where - return = Min - _ >> a = a + (>>) = (*>) Min a >>= f = f a instance MonadFix Min where @@ -389,8 +388,7 @@ instance Applicative Max where Max f <*> Max x = Max (f x) instance Monad Max where - return = Max - _ >> a = a + (>>) = (*>) Max a >>= f = f a instance MonadFix Max where @@ -476,8 +474,7 @@ instance Applicative First where First f <*> First x = First (f x) instance Monad First where - return = First - _ >> a = a + (>>) = (*>) First a >>= f = f a instance MonadFix First where @@ -523,8 +520,7 @@ instance Applicative Last where Last f <*> Last x = Last (f x) instance Monad Last where - return = Last - _ >> a = a + (>>) = (*>) Last a >>= f = f a instance MonadFix Last where @@ -584,14 +580,13 @@ instance Applicative Option where pure a = Option (Just a) Option a <*> Option b = Option (a <*> b) -instance Monad Option where - return = pure + Option Nothing *> _ = Option Nothing + _ *> b = b +instance Monad Option where Option (Just a) >>= k = k a _ >>= _ = Option Nothing - - Option Nothing >> _ = Option Nothing - _ >> b = b + (>>) = (*>) instance Alternative Option where empty = Option Nothing diff --git a/libraries/base/Data/Traversable.hs b/libraries/base/Data/Traversable.hs index 81e639cf37..9da76c6a34 100644 --- a/libraries/base/Data/Traversable.hs +++ b/libraries/base/Data/Traversable.hs @@ -196,9 +196,9 @@ instance Traversable Proxy where {-# INLINE traverse #-} sequenceA _ = pure Proxy {-# INLINE sequenceA #-} - mapM _ _ = return Proxy + mapM _ _ = pure Proxy {-# INLINE mapM #-} - sequence _ = return Proxy + sequence _ = pure Proxy {-# INLINE sequence #-} instance Traversable (Const m) where diff --git a/libraries/base/Data/Version.hs b/libraries/base/Data/Version.hs index aba8cf7f74..414b2aa859 100644 --- a/libraries/base/Data/Version.hs +++ b/libraries/base/Data/Version.hs @@ -36,7 +36,8 @@ module Data.Version ( makeVersion ) where -import Control.Monad ( Monad(..), liftM ) +import Data.Functor ( Functor(..) ) +import Control.Applicative ( Applicative(..) ) import Data.Bool ( (&&) ) import Data.Char ( isDigit, isAlphaNum ) import Data.Eq @@ -120,9 +121,9 @@ showVersion (Version branch tags) -- | A parser for versions in the format produced by 'showVersion'. -- parseVersion :: ReadP Version -parseVersion = do branch <- sepBy1 (liftM read (munch1 isDigit)) (char '.') - tags <- many (char '-' >> munch1 isAlphaNum) - return Version{versionBranch=branch, versionTags=tags} +parseVersion = do branch <- sepBy1 (fmap read (munch1 isDigit)) (char '.') + tags <- many (char '-' *> munch1 isAlphaNum) + pure Version{versionBranch=branch, versionTags=tags} -- | Construct tag-less 'Version' -- |