diff options
-rw-r--r-- | libraries/base/GHC/Base.hs | 3 | ||||
-rw-r--r-- | libraries/base/changelog.md | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T7627.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci011.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/tcfail181.stderr | 2 |
5 files changed, 8 insertions, 1 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: diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 849a7adfb6..f4021892c0 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -17,6 +17,8 @@ * `Dual`, `Product`, and `Sum` now have `Functor`, `Applicative`, and `Monad` instances + * `(,) a` now has a `Monad` instance + * Redundant typeclass constraints have been removed: - `Data.Ratio.{denominator,numerator}` have no `Integral` constraint anymore - **TODO** diff --git a/testsuite/tests/ghci/scripts/T7627.stdout b/testsuite/tests/ghci/scripts/T7627.stdout index 27135662d4..158672cc2a 100644 --- a/testsuite/tests/ghci/scripts/T7627.stdout +++ b/testsuite/tests/ghci/scripts/T7627.stdout @@ -15,6 +15,7 @@ data (,) a b = (,) a b -- Defined in ‘GHC.Tuple’ instance (Bounded a, Bounded b) => Bounded (a, b) -- Defined in ‘GHC.Enum’ instance (Eq a, Eq b) => Eq (a, b) -- Defined in ‘GHC.Classes’ +instance Monoid a => Monad ((,) a) -- Defined in ‘GHC.Base’ instance Functor ((,) a) -- Defined in ‘GHC.Base’ instance (Ord a, Ord b) => Ord (a, b) -- Defined in ‘GHC.Classes’ instance (Read a, Read b) => Read (a, b) -- Defined in ‘GHC.Read’ diff --git a/testsuite/tests/ghci/scripts/ghci011.stdout b/testsuite/tests/ghci/scripts/ghci011.stdout index a608f079b5..8042757541 100644 --- a/testsuite/tests/ghci/scripts/ghci011.stdout +++ b/testsuite/tests/ghci/scripts/ghci011.stdout @@ -21,6 +21,7 @@ data (,) a b = (,) a b -- Defined in ‘GHC.Tuple’ instance (Bounded a, Bounded b) => Bounded (a, b) -- Defined in ‘GHC.Enum’ instance (Eq a, Eq b) => Eq (a, b) -- Defined in ‘GHC.Classes’ +instance Monoid a => Monad ((,) a) -- Defined in ‘GHC.Base’ instance Functor ((,) a) -- Defined in ‘GHC.Base’ instance (Ord a, Ord b) => Ord (a, b) -- Defined in ‘GHC.Classes’ instance (Read a, Read b) => Read (a, b) -- Defined in ‘GHC.Read’ diff --git a/testsuite/tests/typecheck/should_fail/tcfail181.stderr b/testsuite/tests/typecheck/should_fail/tcfail181.stderr index e6380995bb..787b62e330 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail181.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail181.stderr @@ -10,7 +10,7 @@ tcfail181.hs:17:9: instance Monad Maybe -- Defined in ‘GHC.Base’ instance Monad IO -- Defined in ‘GHC.Base’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ - ...plus one other + ...plus two others In the expression: foo In the expression: foo {bar = return True} In an equation for ‘wog’: wog x = foo {bar = return True} |