summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Base.hs
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2015-02-08 20:56:58 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2015-02-09 10:05:59 +0100
commita741e69a230eb6d6e3373ad1fbe53c73b5f95077 (patch)
tree16789eb1edbff08eddde495e371a3893154adfa1 /libraries/base/GHC/Base.hs
parent9bc13c0705fbc08989eb9f51dd8691dadc855747 (diff)
downloadhaskell-a741e69a230eb6d6e3373ad1fbe53c73b5f95077.tar.gz
Provide default implementation of `Monad(return)`
This was dropped last-minute from d94de87252d0fe2ae97341d186b03a2fbe136b04 (re #4834) together with the default implementation for `(>>)` (see 65f887e1a0d864526f6a2609a3afc2c151c25e38 for explanation). However, the risk of accidental mutually recursive definitions of `return`/`pure` is rather low as unlike with the `(>>) = (*>)` default, any cyclic definitions would necessarily wind up being new ones, rather than changing the semantics for old operations and introducing bottoms. On the other hand, not having the default method implementation in place in GHC 7.10 would complicate/delay any future attempt to clean-up the `Monad`-class. This finally allows (for `base >= 4.8`) to define a F/A/M instance-chain with the following minimal definitions (while ignoring that `return` is still a class-method in `Monad`) instance Functor M where fmap = ... instance Applicative M where pure = ... (<*>) = ... instance Monad M where (>>=) = ... Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D647
Diffstat (limited to 'libraries/base/GHC/Base.hs')
-rw-r--r--libraries/base/GHC/Base.hs1
1 files changed, 1 insertions, 0 deletions
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index 44085a2efa..7e04ab4f0e 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -468,6 +468,7 @@ class Applicative m => Monad m where
-- | Inject a value into the monadic type.
return :: a -> m a
+ return = pure
-- | Fail with a message. This operation is not part of the
-- mathematical definition of a monad, but is invoked on pattern-match