[commit: packages/base] master: Add RULE for "map coerce = map" (#8767) (f96dc54)

git at git.haskell.org git at git.haskell.org
Thu Mar 13 22:59:56 UTC 2014


Repository : ssh://git@git.haskell.org/base

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/f96dc5470355ce52741c717b6387d7f61b6a8dc1/base

>---------------------------------------------------------------

commit f96dc5470355ce52741c717b6387d7f61b6a8dc1
Author: Austin Seipp <austin at well-typed.com>
Date:   Thu Mar 13 16:51:34 2014 -0500

    Add RULE for "map coerce = map" (#8767)
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


>---------------------------------------------------------------

f96dc5470355ce52741c717b6387d7f61b6a8dc1
 GHC/Base.lhs |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/GHC/Base.lhs b/GHC/Base.lhs
index 0a2dd80..bb605e7 100644
--- a/GHC/Base.lhs
+++ b/GHC/Base.lhs
@@ -400,6 +400,17 @@ mapFB c f = \x ys -> c (f x) ys
 "mapList"   [1]  forall f.      foldr (mapFB (:) f) []  = map f
 "mapFB"     forall c f g.       mapFB (mapFB c f) g     = mapFB c (f.g)
   #-}
+
+-- There's also a rule for Map and Data.Coerce. See "Safe Coercions",
+-- section 6.4:
+--
+--   http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/coercible.pdf
+--
+-- We rewrite late so the optimiser has as many chances as possible to
+-- turn up instances of map coerce.
+
+{-# RULES "map/coerce" map coerce = coerce #-}
+
 \end{code}
 
 



More information about the ghc-commits mailing list