[commit: packages/containers] develop-0.6, develop-0.6-questionable, master, zip-devel: Merge pull request #66 from treeowl/seqfmapcoerce (e083f68)

git at git.haskell.org git at git.haskell.org
Fri Jan 23 22:41:14 UTC 2015


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

On branches: develop-0.6,develop-0.6-questionable,master,zip-devel
Link       : http://git.haskell.org/packages/containers.git/commitdiff/e083f683d833d6ffd98b7b91f27c1e10a2cded97

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

commit e083f683d833d6ffd98b7b91f27c1e10a2cded97
Merge: 94fa013 ad24ce6
Author: Milan Straka <fox at ucw.cz>
Date:   Tue Nov 18 14:50:46 2014 +0100

    Merge pull request #66 from treeowl/seqfmapcoerce
    
    Implement fmap/coerce rules



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

e083f683d833d6ffd98b7b91f27c1e10a2cded97
 Data/Map/Base.hs               | 24 +++++++++++++++++-------
 Data/Map/Strict.hs             | 19 ++++++++++++++++++-
 Data/Sequence.hs               | 27 ++++++++++++++++++++-------
 Data/Tree.hs                   | 29 ++++++++++++++++++++++-------
 tests-ghc/all.T                |  3 +++
 tests-ghc/mapcoercemap.hs      | 25 +++++++++++++++++++++++++
 tests-ghc/mapcoercemap.stdout  |  3 +++
 tests-ghc/mapcoerceseq.hs      | 25 +++++++++++++++++++++++++
 tests-ghc/mapcoerceseq.stdout  |  3 +++
 tests-ghc/mapcoercesmap.hs     | 25 +++++++++++++++++++++++++
 tests-ghc/mapcoercesmap.stdout |  3 +++
 11 files changed, 164 insertions(+), 22 deletions(-)

diff --cc Data/Sequence.hs
index 0c2be04,0bef765..1c4e143
--- a/Data/Sequence.hs
+++ b/Data/Sequence.hs
@@@ -187,8 -189,18 +189,19 @@@ instance Functor Seq wher
      x <$ s = replicate (length s) x
  #endif
  
+ fmapSeq :: (a -> b) -> Seq a -> Seq b
+ fmapSeq f (Seq xs) = Seq (fmap (fmap f) xs)
+ #if MIN_VERSION_base(4,8,0)
+ -- Safe coercions were introduced in 4.7.0, but I am not sure if they played
+ -- well enough with RULES to do what we want.
+ {-# NOINLINE [1] fmapSeq #-}
+ {-# RULES
+ "fmapSeq/coerce" fmapSeq coerce = coerce
+  #-}
+ #endif
+ 
  instance Foldable Seq where
 +    foldMap f (Seq xs) = foldMap (foldMap f) xs
      foldr f z (Seq xs) = foldr (flip (foldr f)) z xs
      foldl f z (Seq xs) = foldl (foldl f) z xs
  



More information about the ghc-commits mailing list