Commit 7cf87fc6 authored by David Feuer's avatar David Feuer Committed by Austin Seipp

Eta-expand argument to foldr in mapM_ for []

Summary:
This improves performance, at least sometimes--the previous
implementation can be worse than the version in base 4.7. I
have not had the time to run benchmarks and such, but `mapM`
already does this.

Also, inline `mapM_`, like `mapM`.

Reviewers: hvr, nomeata, ekmett, austin

Reviewed By: ekmett, austin

Subscribers: thomie

Projects: #ghc

Differential Revision: https://phabricator.haskell.org/D632

GHC Trac Issues: #10034
parent ae39c5c0
......@@ -349,7 +349,8 @@ for_ = flip traverse_
-- As of base 4.8.0.0, 'mapM_' is just 'traverse_', specialized to
-- 'Monad'.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
mapM_ f= foldr ((>>) . f) (return ())
{-# INLINE mapM_ #-}
mapM_ f = foldr (\m n -> f m >> n) (return ())
-- | 'forM_' is 'mapM_' with its arguments flipped. For a version that
-- doesn't ignore the results see 'Data.Traversable.forM'.
......
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