diff options
Diffstat (limited to 'libraries/base/GHC/Word.hs')
-rw-r--r-- | libraries/base/GHC/Word.hs | 81 |
1 files changed, 2 insertions, 79 deletions
diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs index baa878763e..ec231de2b8 100644 --- a/libraries/base/GHC/Word.hs +++ b/libraries/base/GHC/Word.hs @@ -220,13 +220,6 @@ instance FiniteBits Word8 where countTrailingZeros (W8# x#) = I# (word2Int# (ctz8# (word8ToWord# x#))) {-# RULES -"fromIntegral/Word8->Word8" fromIntegral = id :: Word8 -> Word8 -"fromIntegral/Word8->Integer" fromIntegral = toInteger :: Word8 -> Integer -"fromIntegral/a->Word8" fromIntegral = \x -> case fromIntegral x of W# x# -> W8# (wordToWord8# x#) -"fromIntegral/Word8->a" fromIntegral = \(W8# x#) -> fromIntegral (W# (word8ToWord# x#)) - #-} - -{-# RULES "properFraction/Float->(Word8,Float)" properFraction = \x -> case properFraction x of { @@ -419,14 +412,6 @@ byteSwap16 :: Word16 -> Word16 byteSwap16 (W16# w#) = W16# (wordToWord16# (byteSwap16# (word16ToWord# w#))) {-# RULES -"fromIntegral/Word8->Word16" fromIntegral = \(W8# x#) -> W16# (wordToWord16# (word8ToWord# x#)) -"fromIntegral/Word16->Word16" fromIntegral = id :: Word16 -> Word16 -"fromIntegral/Word16->Integer" fromIntegral = toInteger :: Word16 -> Integer -"fromIntegral/a->Word16" fromIntegral = \x -> case fromIntegral x of W# x# -> W16# (wordToWord16# x#) -"fromIntegral/Word16->a" fromIntegral = \(W16# x#) -> fromIntegral (W# (word16ToWord# x#)) - #-} - -{-# RULES "properFraction/Float->(Word16,Float)" properFraction = \x -> case properFraction x of { @@ -597,15 +582,7 @@ instance Integral Word32 where mod x y = rem x y divMod x y = quotRem x y - toInteger (W32# x#) -#if WORD_SIZE_IN_BITS == 32 - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# (word32ToWord# x#) - where - !i# = word2Int# (word32ToWord# x#) -#else - = IS (word2Int# (word32ToWord# x#)) -#endif + toInteger (W32# x#) = integerFromWord# (word32ToWord# x#) -- | @since 2.01 instance Bits Word32 where @@ -651,15 +628,6 @@ instance FiniteBits Word32 where countLeadingZeros (W32# x#) = I# (word2Int# (clz32# (word32ToWord# x#))) countTrailingZeros (W32# x#) = I# (word2Int# (ctz32# (word32ToWord# x#))) -{-# RULES -"fromIntegral/Word8->Word32" fromIntegral = \(W8# x#) -> W32# (wordToWord32# (word8ToWord# x#)) -"fromIntegral/Word16->Word32" fromIntegral = \(W16# x#) -> W32# (wordToWord32# (word16ToWord# x#)) -"fromIntegral/Word32->Word32" fromIntegral = id :: Word32 -> Word32 -"fromIntegral/Word32->Integer" fromIntegral = toInteger :: Word32 -> Integer -"fromIntegral/a->Word32" fromIntegral = \x -> case fromIntegral x of W# x# -> W32# (wordToWord32# x#) -"fromIntegral/Word32->a" fromIntegral = \(W32# x#) -> fromIntegral (W# (word32ToWord# x#)) - #-} - -- | @since 2.01 instance Show Word32 where #if WORD_SIZE_IN_BITS < 33 @@ -833,14 +801,6 @@ a `shiftL64#` b | isTrue# (b >=# 64#) = wordToWord64# 0## a `shiftRL64#` b | isTrue# (b >=# 64#) = wordToWord64# 0## | otherwise = a `uncheckedShiftRL64#` b -{-# RULES -"fromIntegral/Int->Word64" fromIntegral = \(I# x#) -> W64# (int64ToWord64# (intToInt64# x#)) -"fromIntegral/Word->Word64" fromIntegral = \(W# x#) -> W64# (wordToWord64# x#) -"fromIntegral/Word64->Int" fromIntegral = \(W64# x#) -> I# (word2Int# (word64ToWord# x#)) -"fromIntegral/Word64->Word" fromIntegral = \(W64# x#) -> W# (word64ToWord# x#) -"fromIntegral/Word64->Word64" fromIntegral = id :: Word64 -> Word64 - #-} - #else -- Word64 is represented in the same way as Word. @@ -969,11 +929,7 @@ instance Integral Word64 where mod x y = rem x y divMod x y = quotRem x y - toInteger (W64# x#) - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# + toInteger (W64# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word64 where @@ -1010,11 +966,6 @@ instance Bits Word64 where bit = bitDefault testBit = testBitDefault -{-# RULES -"fromIntegral/a->Word64" fromIntegral = \x -> case fromIntegral x of W# x# -> W64# x# -"fromIntegral/Word64->a" fromIntegral = \(W64# x#) -> fromIntegral (W# x#) - #-} - uncheckedShiftL64# :: Word# -> Int# -> Word# uncheckedShiftL64# = uncheckedShiftL# @@ -1092,34 +1043,6 @@ bitReverse64 (W64# w#) = W64# (bitReverse# w#) ------------------------------------------------------------------------------- -{-# RULES -"fromIntegral/Natural->Word8" - fromIntegral = (fromIntegral :: Word -> Word8) . naturalToWord -"fromIntegral/Natural->Word16" - fromIntegral = (fromIntegral :: Word -> Word16) . naturalToWord -"fromIntegral/Natural->Word32" - fromIntegral = (fromIntegral :: Word -> Word32) . naturalToWord - #-} - -{-# RULES -"fromIntegral/Word8->Natural" - fromIntegral = naturalFromWord . (fromIntegral :: Word8 -> Word) -"fromIntegral/Word16->Natural" - fromIntegral = naturalFromWord . (fromIntegral :: Word16 -> Word) -"fromIntegral/Word32->Natural" - fromIntegral = naturalFromWord . (fromIntegral :: Word32 -> Word) - #-} - -#if WORD_SIZE_IN_BITS == 64 --- these RULES are valid for Word==Word64 -{-# RULES -"fromIntegral/Natural->Word64" - fromIntegral = (fromIntegral :: Word -> Word64) . naturalToWord -"fromIntegral/Word64->Natural" - fromIntegral = naturalFromWord . (fromIntegral :: Word64 -> Word) - #-} -#endif - shiftRLWord8# :: Word8# -> Int# -> Word8# a `shiftRLWord8#` b | isTrue# (b >=# 8#) = wordToWord8# 0## | otherwise = a `uncheckedShiftRLWord8#` b |