Commit e7480063 authored by Vilem-Benjamin Liepelt's avatar Vilem-Benjamin Liepelt Committed by Marge Bot

Piggyback on Enum Word methods for Word64

If we are on a 64 bit platform, we can use the efficient Enum Word
methods for the Enum Word64 instance.
parent b552e531
......@@ -892,10 +892,44 @@ instance Enum Word64 where
| x <= fromIntegral (maxBound::Int)
= I# (word2Int# x#)
| otherwise = fromEnumError "Word64" x
enumFrom = integralEnumFrom
enumFromThen = integralEnumFromThen
enumFromTo = integralEnumFromTo
enumFromThenTo = integralEnumFromThenTo
#if WORD_SIZE_IN_BITS < 64
enumFrom = integralEnumFrom
enumFromThen = integralEnumFromThen
enumFromTo = integralEnumFromTo
enumFromThenTo = integralEnumFromThenTo
#else
-- See Note [Stable Unfolding for list producers] in GHC.Enum
{-# INLINABLE enumFrom #-}
enumFrom w
= map wordToWord64
$ enumFrom (word64ToWord w)
-- See Note [Stable Unfolding for list producers] in GHC.Enum
{-# INLINABLE enumFromThen #-}
enumFromThen w s
= map wordToWord64
$ enumFromThen (word64ToWord w) (word64ToWord s)
-- See Note [Stable Unfolding for list producers] in GHC.Enum
{-# INLINABLE enumFromTo #-}
enumFromTo w1 w2
= map wordToWord64
$ enumFromTo (word64ToWord w1) (word64ToWord w2)
-- See Note [Stable Unfolding for list producers] in GHC.Enum
{-# INLINABLE enumFromThenTo #-}
enumFromThenTo w1 s w2
= map wordToWord64
$ enumFromThenTo (word64ToWord w1) (word64ToWord s) (word64ToWord w2)
word64ToWord :: Word64 -> Word
word64ToWord (W64# w#) = (W# w#)
wordToWord64 :: Word -> Word64
wordToWord64 (W# w#) = (W64# w#)
#endif
-- | @since 2.01
instance Integral Word64 where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment