summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Word.hs
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-10-27 17:18:51 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-29 05:02:25 -0400
commit7170052651ff02bfcf1e9611f0813dd20a7c8558 (patch)
tree19f4b1baa46eb0158f0e929117f86182ec07638d /libraries/base/GHC/Word.hs
parent522eab3f056905db47110c73dac1833f4a2880f2 (diff)
downloadhaskell-7170052651ff02bfcf1e9611f0813dd20a7c8558.tar.gz
Add more INLINABLE and INLINE pragmas to `Enum Int*` instances
Otherwise the instances aren't good list producers. See Note [Stable Unfolding for list producers].
Diffstat (limited to 'libraries/base/GHC/Word.hs')
-rw-r--r--libraries/base/GHC/Word.hs36
1 files changed, 32 insertions, 4 deletions
diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs
index dd803c55b4..be44bfd541 100644
--- a/libraries/base/GHC/Word.hs
+++ b/libraries/base/GHC/Word.hs
@@ -136,7 +136,11 @@ instance Enum Word8 where
= W8# (wordToWord8# (int2Word# i#))
| otherwise = toEnumError "Word8" i (minBound::Word8, maxBound::Word8)
fromEnum (W8# x#) = I# (word2Int# (word8ToWord# x#))
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFrom #-}
enumFrom = boundedEnumFrom
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThen #-}
enumFromThen = boundedEnumFromThen
-- | @since 2.01
@@ -322,7 +326,11 @@ instance Enum Word16 where
= W16# (wordToWord16# (int2Word# i#))
| otherwise = toEnumError "Word16" i (minBound::Word16, maxBound::Word16)
fromEnum (W16# x#) = I# (word2Int# (word16ToWord# x#))
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFrom #-}
enumFrom = boundedEnumFrom
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThen #-}
enumFromThen = boundedEnumFromThen
-- | @since 2.01
@@ -555,7 +563,11 @@ instance Enum Word32 where
enumFromThenTo = integralEnumFromThenTo
#else
fromEnum (W32# x#) = I# (word2Int# (word32ToWord# x#))
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFrom #-}
enumFrom = boundedEnumFrom
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThen #-}
enumFromThen = boundedEnumFromThen
#endif
@@ -724,9 +736,17 @@ instance Enum Word64 where
| x <= fromIntegral (maxBound::Int)
= I# (word2Int# (word64ToWord# x#))
| otherwise = fromEnumError "Word64" x
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFrom #-}
enumFrom = integralEnumFrom
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThen #-}
enumFromThen = integralEnumFromThen
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromTo #-}
enumFromTo = integralEnumFromTo
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThenTo #-}
enumFromThenTo = integralEnumFromThenTo
-- | @since 2.01
@@ -869,10 +889,18 @@ instance Enum Word64 where
| otherwise = fromEnumError "Word64" x
#if WORD_SIZE_IN_BITS < 64
- enumFrom = integralEnumFrom
- enumFromThen = integralEnumFromThen
- enumFromTo = integralEnumFromTo
- enumFromThenTo = integralEnumFromThenTo
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFrom #-}
+ enumFrom = integralEnumFrom
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThen #-}
+ enumFromThen = integralEnumFromThen
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromTo #-}
+ enumFromTo = integralEnumFromTo
+ -- See Note [Stable Unfolding for list producers] in GHC.Enum
+ {-# INLINE enumFromThenTo #-}
+ enumFromThenTo = integralEnumFromThenTo
#else
-- See Note [Stable Unfolding for list producers] in GHC.Enum
{-# INLINABLE enumFrom #-}