takeWhile&C. still not fusible
takeWhile is not still fusible, 2 1/2 years after this report:
The discussion suggests making takeWhile a good producer/consumer with foldr/build fusion:
takeWhile' :: (a -> Bool) -> [a] -> [a] takeWhile' p xs = build $ \c n -> foldr (takeWhileF p c n) n xs # INLINE takeWhile' #
takeWhileF p c n x xs = if p x then x
c xs else n
Furthermore, the discussion suggests having rewrite rules to go to this version and then rewrite back (if fusion fails).
The report also mentions concatMap (which is a separate known problem). It also mentions drop and dropWhile, but I don't see when they perform allocations, so I think that's an erroneous request.
I experienced the bug on GHC 7.6.3, but it seems still there in base-18.104.22.168, judging from the source: http://hackage.haskell.org/package/base-22.214.171.124/docs/src/GHC-List.html\#takeWhile