[commit: ghc] master: Make Data.List.concatMap fuse better (1e269bf)

git at git.haskell.org git at git.haskell.org
Tue Oct 21 21:50:46 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/1e269bf404fb2719bbe8d72154156ef275c9a6f9/ghc

>---------------------------------------------------------------

commit 1e269bf404fb2719bbe8d72154156ef275c9a6f9
Author: David Feuer <David.Feuer at gmail.com>
Date:   Tue Oct 21 15:02:03 2014 -0500

    Make Data.List.concatMap fuse better
    
    Summary:
    Fix #9537 precisely as Joachim Breitner proposed in
    http://www.haskell.org/pipermail/haskell-cafe/2011-December/097228.html
    
    Reviewers: austin, nomeata
    
    Reviewed By: austin, nomeata
    
    Subscribers: thomie, carter, ezyang, simonmar
    
    Differential Revision: https://phabricator.haskell.org/D348
    
    GHC Trac Issues: #9537


>---------------------------------------------------------------

1e269bf404fb2719bbe8d72154156ef275c9a6f9
 libraries/base/GHC/List.lhs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libraries/base/GHC/List.lhs b/libraries/base/GHC/List.lhs
index 7792eed..2d01678 100644
--- a/libraries/base/GHC/List.lhs
+++ b/libraries/base/GHC/List.lhs
@@ -717,6 +717,14 @@ lookup  key ((x,y):xys)
 concatMap               :: (a -> [b]) -> [a] -> [b]
 concatMap f             =  foldr ((++) . f) []
 
+{-# NOINLINE [1] concatMap #-}
+
+{-# RULES
+"concatMap" forall f xs . concatMap f xs =
+    build (\c n -> foldr (\x b -> foldr c b (f x)) n xs)
+ #-}
+
+
 -- | Concatenate a list of lists.
 concat :: [[a]] -> [a]
 concat = foldr (++) []



More information about the ghc-commits mailing list