Commit 6d69c3a2 authored by Ben Gamari's avatar Ben Gamari 🐢
Browse files

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
parent 5857e0af
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment