summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Arr.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-02-06 12:32:01 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2015-02-06 12:40:42 +0000
commitda78af367dfa5050c2c19b758ab046218ee4dd91 (patch)
tree933db3b8616cd697c269bac09d5f1bf81d0e5d01 /libraries/base/GHC/Arr.hs
parent2f13cd88de8ab045737d8447d8d5e0f7ac7ae9f9 (diff)
downloadhaskell-da78af367dfa5050c2c19b758ab046218ee4dd91.tar.gz
Comments only
Diffstat (limited to 'libraries/base/GHC/Arr.hs')
-rw-r--r--libraries/base/GHC/Arr.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/libraries/base/GHC/Arr.hs b/libraries/base/GHC/Arr.hs
index 8b7a2afae0..ee666eb34d 100644
--- a/libraries/base/GHC/Arr.hs
+++ b/libraries/base/GHC/Arr.hs
@@ -706,7 +706,7 @@ unsafeAccum f arr ies = runST (do
STArray l u n marr# <- thawSTArray arr
ST (foldr (adjust f marr#) (done l u n marr#) ies))
-{-# INLINE [1] amap #-}
+{-# INLINE [1] amap #-} -- See Note [amap]
amap :: (a -> b) -> Array i a -> Array i b
amap f arr@(Array l u n@(I# n#) _) = runST (ST $ \s1# ->
case newArray# n# arrEleBottom s1# of
@@ -716,7 +716,8 @@ amap f arr@(Array l u n@(I# n#) _) = runST (ST $ \s1# ->
| otherwise = fill marr# (i, f (unsafeAt arr i)) (go (i+1)) s#
in go 0 s2# )
-{-
+{- Note [amap]
+~~~~~~~~~~~~~~
amap was originally defined like this:
amap f arr@(Array l u n _) =
@@ -725,11 +726,12 @@ amap was originally defined like this:
There are two problems:
1. The enumFromTo implementation produces (spurious) code for the impossible
-case of n<0 that ends up duplicating the array freezing code.
+ case of n<0 that ends up duplicating the array freezing code.
-2. This implementation relies on list fusion for efficiency. In order to
-implement the amap/coerce rule, we need to delay inlining amap until simplifier
-phase 1, which is when the eftIntList rule kicks in and makes that impossible.
+2. This implementation relies on list fusion for efficiency. In order
+ to implement the "amap/coerce" rule, we need to delay inlining amap
+ until simplifier phase 1, which is when the eftIntList rule kicks
+ in and makes that impossible. (c.f. Trac #8767)
-}
@@ -737,7 +739,7 @@ phase 1, which is when the eftIntList rule kicks in and makes that impossible.
-- Coercions for Haskell", section 6.5:
-- http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/coercible.pdf
{-# RULES
-"amap/coerce" amap coerce = coerce
+"amap/coerce" amap coerce = coerce -- See Note [amap]
#-}
-- Second functor law: