diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-07-07 17:07:06 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-07-07 19:17:56 +0200 |
commit | 6d69c3a264a1cfbbc7ecda0e704598afa45848c2 (patch) | |
tree | 985e3c6a3d6d342544698a257f4bcd3471f025aa /libraries | |
parent | 5857e0afb5823987e84e6d3dd8d0b269b7546166 (diff) | |
download | haskell-6d69c3a264a1cfbbc7ecda0e704598afa45848c2.tar.gz |
Generalize `Control.Monad.forever`
This generalizes forever to depend on Applicative, rather than Monad.
This was proposed a month ago
(https://mail.haskell.org/pipermail/libraries/2015-May/025711.html).
Differential Revision: https://phabricator.haskell.org/D1045
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/Control/Monad.hs | 4 | ||||
-rw-r--r-- | libraries/base/changelog.md | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/libraries/base/Control/Monad.hs b/libraries/base/Control/Monad.hs index 6fa4a077d4..be3765d5e2 100644 --- a/libraries/base/Control/Monad.hs +++ b/libraries/base/Control/Monad.hs @@ -113,9 +113,9 @@ f >=> g = \x -> f x >>= g (<=<) = flip (>=>) -- | @'forever' act@ repeats the action infinitely. -forever :: (Monad m) => m a -> m b +forever :: (Applicative f) => f a -> f b {-# INLINE forever #-} -forever a = let a' = a >> a' in a' +forever a = let a' = a *> a' in a' -- Use explicit sharing here, as it is prevents a space leak regardless of -- optimizations. diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 363210dbc6..bb09199093 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -40,6 +40,8 @@ * Generalize `Debug.Trace.{traceM, traceShowM}` from `Monad` to `Applicative` (#10023) + * Generalise `forever` from `Monad` to `Applicative` + ## 4.8.1.0 *TBA* * Bundled with GHC 7.10.2 |