summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Feuer <David.Feuer@gmail.com>2014-10-01 15:57:27 +0200
committerJoachim Breitner <mail@joachim-breitner.de>2014-10-01 18:20:26 +0200
commit789321098f86fd3c4483b24372f8938f89b12312 (patch)
tree6ca281bb51fda372bbedc281c73c749ecd947272
parentd41dd03fdf0ef723ca31f5a11f07a54a15d2cbc0 (diff)
downloadhaskell-789321098f86fd3c4483b24372f8938f89b12312.tar.gz
Fusion rule for "foldr k z (x:build g)"
There seem to be various issues with general fold/cons and even cons/build rules, but it seems pretty clear to me that the simple fold/cons/build rule is a good idea. It doesn't do much for nofib allocation, but it seems to improve some other analyses and speed several benchmarks up. Implements #9536.
-rw-r--r--libraries/base/GHC/Base.lhs3
1 files changed, 3 insertions, 0 deletions
diff --git a/libraries/base/GHC/Base.lhs b/libraries/base/GHC/Base.lhs
index 8b51c07645..f9d01b5269 100644
--- a/libraries/base/GHC/Base.lhs
+++ b/libraries/base/GHC/Base.lhs
@@ -788,6 +788,9 @@ augment g xs = g (:) xs
"foldr/single" forall k z x. foldr k z [x] = k x z
"foldr/nil" forall k z. foldr k z [] = z
+"foldr/cons/build" forall k z x (g::forall b. (a->b->b) -> b -> b) .
+ foldr k z (x:build g) = k x (g k z)
+
"augment/build" forall (g::forall b. (a->b->b) -> b -> b)
(h::forall b. (a->b->b) -> b -> b) .
augment g (build h) = build (\c n -> g c (h c n))