summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorDavid Feuer <david.feuer@gmail.com>2015-02-05 17:42:50 -0600
committerAustin Seipp <austin@well-typed.com>2015-02-05 17:42:50 -0600
commit7cf87fc6928f0252d9f61719e2344e6c69237079 (patch)
treec278359497761c1a07481281ce0665f025122d41 /libraries
parentae39c5c040f121947e14877c3ceb47bbe80c0ccb (diff)
downloadhaskell-7cf87fc6928f0252d9f61719e2344e6c69237079.tar.gz
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
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/Data/Foldable.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/libraries/base/Data/Foldable.hs b/libraries/base/Data/Foldable.hs
index a745f66092..b8b0973a8c 100644
--- a/libraries/base/Data/Foldable.hs
+++ b/libraries/base/Data/Foldable.hs
@@ -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'.