summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Base.hs
diff options
context:
space:
mode:
authorFumiaki Kinoshita <fumiexcel@gmail.com>2015-03-25 13:30:25 +0900
committerHerbert Valerio Riedel <hvr@gnu.org>2015-03-25 14:47:22 +0100
commit9db005a444722e31aca1956b058e069bcf3cacbd (patch)
tree47c433696d584c5a3138eff13e638832027d30c1 /libraries/base/GHC/Base.hs
parent33cfa5ff9db4e7886b3e7c2eed5ac1c75436bc4c (diff)
downloadhaskell-9db005a444722e31aca1956b058e069bcf3cacbd.tar.gz
Add Monad instance for `((,) a)` (#10190)
This was proposed a couple of times in the past, e.g. - https://mail.haskell.org/pipermail/libraries/2011-November/017153.html - https://mail.haskell.org/pipermail/libraries/2013-July/020446.html but its implementation had been blocked by the fact that `Monoid` wasn't in scope where the `Monad` class was defined. Since the AMP/FTP restructuring this is no longer the case.
Diffstat (limited to 'libraries/base/GHC/Base.hs')
-rw-r--r--libraries/base/GHC/Base.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index 7e04ab4f0e..d9192d7a99 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -308,6 +308,9 @@ instance Monoid a => Applicative ((,) a) where
pure x = (mempty, x)
(u, f) <*> (v, x) = (u `mappend` v, f x)
+instance Monoid a => Monad ((,) a) where
+ return x = (mempty, x)
+ (u, a) >>= k = case k a of (v, b) -> (u `mappend` v, b)
{- | The 'Functor' class is used for types that can be mapped over.
Instances of 'Functor' should satisfy the following laws: