Commit 2fa44217 authored by Joachim Breitner's avatar Joachim Breitner Committed by Ben Gamari

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
parent 2f115a13
......@@ -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
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment