From: Roman Leshchinskiy Date: Wed, 25 Nov 2009 01:00:03 +0000 (+0000) Subject: Make sure zipWithFB has arity 2 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=688a7522048e7da103ea835d224f9e34ee1a615e;p=ghc-base.git Make sure zipWithFB has arity 2 It gets 2 arguments in the "zipWith" rule but its arity was higher and the new inliner didn't inline it sometimes, for instance here: mpp :: [Double] -> [Double] -> [Double] -> [Double] -> [Double] mpp as bs cs ds = zipWith (*) (zipWith (+) as bs) (zipWith (+) cs ds) This was a regression vs. 6.10. --- diff --git a/GHC/List.lhs b/GHC/List.lhs index 5dcf7e0..87a9dbd 100644 --- a/GHC/List.lhs +++ b/GHC/List.lhs @@ -680,9 +680,11 @@ zipWith :: (a->b->c) -> [a]->[b]->[c] zipWith f (a:as) (b:bs) = f a b : zipWith f as bs zipWith _ _ _ = [] +-- zipWithFB must have arity 2 since it gets two arguments in the "zipWith" +-- rule; it might not get inlined otherwise {-# INLINE [0] zipWithFB #-} zipWithFB :: (a -> b -> c) -> (d -> e -> a) -> d -> e -> b -> c -zipWithFB c f x y r = (x `f` y) `c` r +zipWithFB c f = \x y r -> (x `f` y) `c` r {-# RULES "zipWith" [~1] forall f xs ys. zipWith f xs ys = build (\c n -> foldr2 (zipWithFB c f) n xs ys)