Skip to content

Commit

Permalink
Generalize Control.Monad.forever
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bgamari committed Jul 7, 2015
1 parent 5857e0a commit 6d69c3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/base/Control/Monad.hs
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions libraries/base/changelog.md
Expand Up @@ -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
Expand Down

0 comments on commit 6d69c3a

Please sign in to comment.