summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-04-04 15:13:02 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2017-04-04 15:13:02 +0100
commite21eac3a4f0503ea3f6e53eef62226cf4f53c574 (patch)
tree6f21de74d66038b3df0fc000fcbbd8705ab5deb0
parentf95f7a7afc07bc545aec7758b10a7931b1dc0381 (diff)
downloadhaskell-wip/cheap-build.tar.gz
Move forcing of enumFromT arguemnts inwardswip/cheap-build
Proof of concept. See comments on Trac #13422
-rw-r--r--libraries/base/GHC/Enum.hs37
1 files changed, 19 insertions, 18 deletions
diff --git a/libraries/base/GHC/Enum.hs b/libraries/base/GHC/Enum.hs
index 1df43b0ca7..c65db90cc9 100644
--- a/libraries/base/GHC/Enum.hs
+++ b/libraries/base/GHC/Enum.hs
@@ -435,12 +435,12 @@ instance Enum Int where
fromEnum x = x
{-# INLINE enumFrom #-}
- enumFrom (I# x) = eftInt x maxInt#
- where !(I# maxInt#) = maxInt
+ enumFrom x = eftInt x maxInt
+-- where !(I# maxInt#) = maxInt
-- Blarg: technically I guess enumFrom isn't strict!
{-# INLINE enumFromTo #-}
- enumFromTo (I# x) (I# y) = eftInt x y
+ enumFromTo x y = eftInt x y
{-# INLINE enumFromThen #-}
enumFromThen (I# x1) (I# x2) = efdInt x1 x2
@@ -467,24 +467,25 @@ instance Enum Int where
-}
{-# NOINLINE [1] eftInt #-}
-eftInt :: Int# -> Int# -> [Int]
+eftInt :: Int -> Int -> [Int]
-- [x1..x2]
-eftInt x0 y | isTrue# (x0 ># y) = []
- | otherwise = go x0
- where
- go x = I# x : if isTrue# (x ==# y)
- then []
- else go (x +# 1#)
+eftInt (I# x0) (I# y)
+ | isTrue# (x0 ># y) = []
+ | otherwise = go x0
+ where
+ go x = I# x : if isTrue# (x ==# y)
+ then []
+ else go (x +# 1#)
{-# INLINE [0] eftIntFB #-} -- See Note [Inline FB functions] in GHC.List
-eftIntFB :: (Int -> r -> r) -> r -> Int# -> Int# -> r
-eftIntFB c n x0 y | isTrue# (x0 ># y) = n
- | otherwise = go x0
- where
- go x = I# x `c` if isTrue# (x ==# y)
- then n
- else go (x +# 1#)
- -- Watch out for y=maxBound; hence ==, not >
+eftIntFB :: (Int -> r -> r) -> r -> Int -> Int -> r
+eftIntFB c n (I# x0) (I# y)
+ | isTrue# (x0 ># y) = n
+ | otherwise = go x0
+ where
+ go x = I# x `c` if isTrue# (x ==# y)
+ then n -- Watch out for y=maxBound; hence ==, not >
+ else go (x +# 1#)
-- Be very careful not to have more than one "c"
-- so that when eftInfFB is inlined we can inline
-- whatever is bound to "c"