[commit: ghc] master: Add rule mapFB c (λx.x) = c (2fa4421)
git at git.haskell.org
git at git.haskell.org
Mon Mar 6 23:51:40 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2fa44217c1d9722227297eefb0d6c6aed7e128ca/ghc
>---------------------------------------------------------------
commit 2fa44217c1d9722227297eefb0d6c6aed7e128ca
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Mon Mar 6 17:30:52 2017 -0500
Add rule mapFB c (λx.x) = c
Test Plan: exended T2110 with a case for that.
Reviewers: austin, hvr, dfeuer, bgamari
Reviewed By: dfeuer
Subscribers: dfeuer, thomie
Differential Revision: https://phabricator.haskell.org/D3275
>---------------------------------------------------------------
2fa44217c1d9722227297eefb0d6c6aed7e128ca
libraries/base/GHC/Base.hs | 1 +
testsuite/tests/simplCore/should_run/T2110.hs | 3 +++
testsuite/tests/simplCore/should_run/T2110.stdout | 1 +
3 files changed, 5 insertions(+)
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index 2f155c6..6f9d454 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -973,6 +973,7 @@ mapFB c f = \x ys -> c (f x) ys
"map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs)
"mapList" [1] forall f. foldr (mapFB (:) f) [] = map f
"mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f.g)
+"mapFB/id" forall c. mapFB c (\x -> x) = c
#-}
-- See Breitner, Eisenberg, Peyton Jones, and Weirich, "Safe Zero-cost
diff --git a/testsuite/tests/simplCore/should_run/T2110.hs b/testsuite/tests/simplCore/should_run/T2110.hs
index 610be09..d945fac 100644
--- a/testsuite/tests/simplCore/should_run/T2110.hs
+++ b/testsuite/tests/simplCore/should_run/T2110.hs
@@ -5,6 +5,8 @@ import Unsafe.Coerce
newtype Age = Age Int
+foo :: [Int] -> [Int]
+foo = map id
fooAge :: [Int] -> [Age]
fooAge = map Age
fooCoerce :: [Int] -> [Age]
@@ -19,6 +21,7 @@ same x y = case reallyUnsafePtrEquality# (unsafeCoerce x) y of
main = do
let l = [1,2,3]
+ same (foo l) l
same (fooAge l) l
same (fooCoerce l) l
same (fooUnsafeCoerce l) l
diff --git a/testsuite/tests/simplCore/should_run/T2110.stdout b/testsuite/tests/simplCore/should_run/T2110.stdout
index 55f7ebb..4ff957b 100644
--- a/testsuite/tests/simplCore/should_run/T2110.stdout
+++ b/testsuite/tests/simplCore/should_run/T2110.stdout
@@ -1,3 +1,4 @@
yes
yes
yes
+yes
More information about the ghc-commits
mailing list