(original) (raw)

{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash, UnboxedTuples #-} {-# OPTIONS_HADDOCK hide #-}

#include "MachDeps.h"

module GHC.Word ( Word(..), Word8(..), Word16(..), Word32(..), Word64(..),

[uncheckedShiftL64#](GHC.Word.html#uncheckedShiftL64%23),
[uncheckedShiftRL64#](GHC.Word.html#uncheckedShiftRL64%23),


[byteSwap16](GHC.Word.html#byteSwap16),
[byteSwap32](GHC.Word.html#byteSwap32),
[byteSwap64](GHC.Word.html#byteSwap64),


eqWord, neWord, gtWord, geWord, ltWord, leWord,
[eqWord8](GHC.Word.html#eqWord8), [neWord8](GHC.Word.html#neWord8), [gtWord8](GHC.Word.html#gtWord8), [geWord8](GHC.Word.html#geWord8), [ltWord8](GHC.Word.html#ltWord8), [leWord8](GHC.Word.html#leWord8),
[eqWord16](GHC.Word.html#eqWord16), [neWord16](GHC.Word.html#neWord16), [gtWord16](GHC.Word.html#gtWord16), [geWord16](GHC.Word.html#geWord16), [ltWord16](GHC.Word.html#ltWord16), [leWord16](GHC.Word.html#leWord16),
[eqWord32](GHC.Word.html#eqWord32), [neWord32](GHC.Word.html#neWord32), [gtWord32](GHC.Word.html#gtWord32), [geWord32](GHC.Word.html#geWord32), [ltWord32](GHC.Word.html#ltWord32), [leWord32](GHC.Word.html#leWord32),
[eqWord64](GHC.Word.html#eqWord64), [neWord64](GHC.Word.html#neWord64), [gtWord64](GHC.Word.html#gtWord64), [geWord64](GHC.Word.html#geWord64), [ltWord64](GHC.Word.html#ltWord64), [leWord64](GHC.Word.html#leWord64)
) where

import Data.Bits import Data.Maybe

#if WORD_SIZE_IN_BITS < 64 import GHC.IntWord64 #endif

import GHC.Base import GHC.Enum import GHC.Num import GHC.Real import GHC.Arr import GHC.Show

data {-# CTYPE "HsWord8" #-} Word8 = W8# Word#

instance Eq Word8 where (==) = eqWord8 (/=) = neWord8

eqWord8, neWord8 :: Word8 -> Word8 -> Bool eqWord8 (W8# x) (W8# y) = isTrue# (x eqWord# y) neWord8 (W8# x) (W8# y) = isTrue# (x neWord# y) {-# INLINE [1] eqWord8 #-} {-# INLINE [1] neWord8 #-}

instance Ord Word8 where (<) = ltWord8 (<=) = leWord8 (>=) = geWord8 (>) = gtWord8

{-# INLINE [1] gtWord8 #-} {-# INLINE [1] geWord8 #-} {-# INLINE [1] ltWord8 #-} {-# INLINE [1] leWord8 #-} gtWord8, geWord8, ltWord8, leWord8 :: Word8 -> Word8 -> Bool (W8# x) [gtWord8](GHC.Word.html#gtWord8) (W8# y) = isTrue# (x gtWord# y) (W8# x) [geWord8](GHC.Word.html#geWord8) (W8# y) = isTrue# (x geWord# y) (W8# x) [ltWord8](GHC.Word.html#ltWord8) (W8# y) = isTrue# (x ltWord# y) (W8# x) [leWord8](GHC.Word.html#leWord8) (W8# y) = isTrue# (x leWord# y)

instance Show Word8 where showsPrec p x = showsPrec p (fromIntegral x :: Int)

instance Num Word8 where (W8# x#) + (W8# y#) = W8# (narrow8Word# (x# plusWord# y#)) (W8# x#) - (W8# y#) = W8# (narrow8Word# (x# minusWord# y#)) (W8# x#) * (W8# y#) = W8# (narrow8Word# (x# timesWord# y#)) negate (W8# x#) = W8# (narrow8Word# (int2Word# (negateInt# (word2Int# x#)))) abs x = x signum 0 = 0 signum _ = 1 fromInteger i = W8# (narrow8Word# (integerToWord i))

instance Real Word8 where toRational x = toInteger x % 1

instance Enum Word8 where succ x | x /= maxBound = x + 1 | otherwise = succError "Word8" pred x | x /= minBound = x - 1 | otherwise = predError "Word8" toEnum i@(I# i#) | i >= 0 && i <= fromIntegral (maxBound::Word8) = W8# (int2Word# i#) | otherwise = toEnumError "Word8" i (minBound::Word8, maxBound::Word8) fromEnum (W8# x#) = I# (word2Int# x#) enumFrom = boundedEnumFrom enumFromThen = boundedEnumFromThen

instance Integral Word8 where quot (W8# x#) y@(W8# y#) | y /= 0 = W8# (x# quotWord# y#) | otherwise = divZeroError rem (W8# x#) y@(W8# y#) | y /= 0 = W8# (x# remWord# y#) | otherwise = divZeroError div (W8# x#) y@(W8# y#) | y /= 0 = W8# (x# quotWord# y#) | otherwise = divZeroError mod (W8# x#) y@(W8# y#) | y /= 0 = W8# (x# remWord# y#) | otherwise = divZeroError quotRem (W8# x#) y@(W8# y#) | y /= 0 = case x# quotRemWord# y# of (# q, r #) -> (W8# q, W8# r) | otherwise = divZeroError divMod (W8# x#) y@(W8# y#) | y /= 0 = (W8# (x# quotWord# y#), W8# (x# remWord# y#)) | otherwise = divZeroError toInteger (W8# x#) = smallInteger (word2Int# x#)

instance Bounded Word8 where minBound = 0 maxBound = 0xFF

instance Ix Word8 where range (m,n) = [m..n] unsafeIndex (m,_) i = fromIntegral (i - m) inRange (m,n) i = m <= i && i <= n

instance Bits Word8 where {-# INLINE shift #-} {-# INLINE bit #-} {-# INLINE testBit #-}

([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060265)) [.&.](Data.Bits.html#.%26.)   ([W8#](GHC.Word.html#W8%23) [y#](#local-6989586621679060266))   = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060265) `and#` [y#](#local-6989586621679060266))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060267)) [.|.](Data.Bits.html#.%7C.)   ([W8#](GHC.Word.html#W8%23) [y#](#local-6989586621679060268))   = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060267) `or#`  [y#](#local-6989586621679060268))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060269)) `[xor](Data.Bits.html#xor)` ([W8#](GHC.Word.html#W8%23) [y#](#local-6989586621679060270))   = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060269) `xor#` [y#](#local-6989586621679060270))
[complement](Data.Bits.html#complement) ([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060271))       = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060271) `xor#` [mb#](#local-6989586621679060272))
    where !([W8#](GHC.Word.html#W8%23) [mb#](#local-6989586621679060272)) = [maxBound](GHC.Enum.html#maxBound)
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060273)) `[shift](Data.Bits.html#shift)` (I# [i#](#local-6989586621679060274))
    | isTrue# ([i#](#local-6989586621679060274) >=# 0#) = [W8#](GHC.Word.html#W8%23) (narrow8Word# ([x#](#local-6989586621679060273) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060274)))
    | [otherwise](GHC.Base.html#otherwise)           = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060273) `[shiftRL#](GHC.Base.html#shiftRL%23)` negateInt# [i#](#local-6989586621679060274))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060275)) `[shiftL](Data.Bits.html#shiftL)`       (I# [i#](#local-6989586621679060276)) = [W8#](GHC.Word.html#W8%23) (narrow8Word# ([x#](#local-6989586621679060275) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060276)))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060277)) `[unsafeShiftL](Data.Bits.html#unsafeShiftL)` (I# [i#](#local-6989586621679060278)) =
    [W8#](GHC.Word.html#W8%23) (narrow8Word# ([x#](#local-6989586621679060277) `uncheckedShiftL#` [i#](#local-6989586621679060278)))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060279)) `[shiftR](Data.Bits.html#shiftR)`       (I# [i#](#local-6989586621679060280)) = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060279) `[shiftRL#](GHC.Base.html#shiftRL%23)` [i#](#local-6989586621679060280))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060281)) `[unsafeShiftR](Data.Bits.html#unsafeShiftR)` (I# [i#](#local-6989586621679060282)) = [W8#](GHC.Word.html#W8%23) ([x#](#local-6989586621679060281) `uncheckedShiftRL#` [i#](#local-6989586621679060282))
([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060283)) `[rotate](Data.Bits.html#rotate)`       (I# [i#](#local-6989586621679060284))
    | isTrue# ([i'#](#local-6989586621679060285) ==# 0#) = [W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060283)
    | [otherwise](GHC.Base.html#otherwise)  = [W8#](GHC.Word.html#W8%23) (narrow8Word# (([x#](#local-6989586621679060283) `uncheckedShiftL#` [i'#](#local-6989586621679060285)) `or#`
                                      ([x#](#local-6989586621679060283) `uncheckedShiftRL#` (8# -# [i'#](#local-6989586621679060285)))))
    where
    ![i'#](#local-6989586621679060285) = word2Int# (int2Word# [i#](#local-6989586621679060284) `and#` 7##)
[bitSizeMaybe](Data.Bits.html#bitSizeMaybe) [i](#local-6989586621679060286)            = [Just](GHC.Maybe.html#Just) ([finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060286))
[bitSize](Data.Bits.html#bitSize) [i](#local-6989586621679060287)                 = [finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060287)
[isSigned](Data.Bits.html#isSigned) _                = False
[popCount](Data.Bits.html#popCount) ([W8#](GHC.Word.html#W8%23) [x#](#local-6989586621679060288))         = I# (word2Int# (popCnt8# [x#](#local-6989586621679060288)))
[bit](Data.Bits.html#bit)                       = [bitDefault](Data.Bits.html#bitDefault)
[testBit](Data.Bits.html#testBit)                   = [testBitDefault](Data.Bits.html#testBitDefault)

instance FiniteBits Word8 where finiteBitSize _ = 8 countLeadingZeros (W8# x#) = I# (word2Int# (clz8# x#)) countTrailingZeros (W8# x#) = I# (word2Int# (ctz8# 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# (narrow8Word# x#) "fromIntegral/Word8->a" fromIntegral = (W8# x#) -> fromIntegral (W# x#) #-}

{-# RULES "properFraction/Float->(Word8,Float)" properFraction = \x -> case properFraction x of { (n, y) -> ((fromIntegral :: Int -> Word8) n, y :: Float) } "truncate/Float->Word8" truncate = (fromIntegral :: Int -> Word8) . (truncate :: Float -> Int) "floor/Float->Word8" floor = (fromIntegral :: Int -> Word8) . (floor :: Float -> Int) "ceiling/Float->Word8" ceiling = (fromIntegral :: Int -> Word8) . (ceiling :: Float -> Int) "round/Float->Word8" round = (fromIntegral :: Int -> Word8) . (round :: Float -> Int) #-}

{-# RULES "properFraction/Double->(Word8,Double)" properFraction = \x -> case properFraction x of { (n, y) -> ((fromIntegral :: Int -> Word8) n, y :: Double) } "truncate/Double->Word8" truncate = (fromIntegral :: Int -> Word8) . (truncate :: Double -> Int) "floor/Double->Word8" floor = (fromIntegral :: Int -> Word8) . (floor :: Double -> Int) "ceiling/Double->Word8" ceiling = (fromIntegral :: Int -> Word8) . (ceiling :: Double -> Int) "round/Double->Word8" round = (fromIntegral :: Int -> Word8) . (round :: Double -> Int) #-}

data {-# CTYPE "HsWord16" #-} Word16 = W16# Word#

instance Eq Word16 where (==) = eqWord16 (/=) = neWord16

eqWord16, neWord16 :: Word16 -> Word16 -> Bool eqWord16 (W16# x) (W16# y) = isTrue# (x eqWord# y) neWord16 (W16# x) (W16# y) = isTrue# (x neWord# y) {-# INLINE [1] eqWord16 #-} {-# INLINE [1] neWord16 #-}

instance Ord Word16 where (<) = ltWord16 (<=) = leWord16 (>=) = geWord16 (>) = gtWord16

{-# INLINE [1] gtWord16 #-} {-# INLINE [1] geWord16 #-} {-# INLINE [1] ltWord16 #-} {-# INLINE [1] leWord16 #-} gtWord16, geWord16, ltWord16, leWord16 :: Word16 -> Word16 -> Bool (W16# x) [gtWord16](GHC.Word.html#gtWord16) (W16# y) = isTrue# (x gtWord# y) (W16# x) [geWord16](GHC.Word.html#geWord16) (W16# y) = isTrue# (x geWord# y) (W16# x) [ltWord16](GHC.Word.html#ltWord16) (W16# y) = isTrue# (x ltWord# y) (W16# x) [leWord16](GHC.Word.html#leWord16) (W16# y) = isTrue# (x leWord# y)

instance Show Word16 where showsPrec p x = showsPrec p (fromIntegral x :: Int)

instance Num Word16 where (W16# x#) + (W16# y#) = W16# (narrow16Word# (x# plusWord# y#)) (W16# x#) - (W16# y#) = W16# (narrow16Word# (x# minusWord# y#)) (W16# x#) * (W16# y#) = W16# (narrow16Word# (x# timesWord# y#)) negate (W16# x#) = W16# (narrow16Word# (int2Word# (negateInt# (word2Int# x#)))) abs x = x signum 0 = 0 signum _ = 1 fromInteger i = W16# (narrow16Word# (integerToWord i))

instance Real Word16 where toRational x = toInteger x % 1

instance Enum Word16 where succ x | x /= maxBound = x + 1 | otherwise = succError "Word16" pred x | x /= minBound = x - 1 | otherwise = predError "Word16" toEnum i@(I# i#) | i >= 0 && i <= fromIntegral (maxBound::Word16) = W16# (int2Word# i#) | otherwise = toEnumError "Word16" i (minBound::Word16, maxBound::Word16) fromEnum (W16# x#) = I# (word2Int# x#) enumFrom = boundedEnumFrom enumFromThen = boundedEnumFromThen

instance Integral Word16 where quot (W16# x#) y@(W16# y#) | y /= 0 = W16# (x# quotWord# y#) | otherwise = divZeroError rem (W16# x#) y@(W16# y#) | y /= 0 = W16# (x# remWord# y#) | otherwise = divZeroError div (W16# x#) y@(W16# y#) | y /= 0 = W16# (x# quotWord# y#) | otherwise = divZeroError mod (W16# x#) y@(W16# y#) | y /= 0 = W16# (x# remWord# y#) | otherwise = divZeroError quotRem (W16# x#) y@(W16# y#) | y /= 0 = case x# quotRemWord# y# of (# q, r #) -> (W16# q, W16# r) | otherwise = divZeroError divMod (W16# x#) y@(W16# y#) | y /= 0 = (W16# (x# quotWord# y#), W16# (x# remWord# y#)) | otherwise = divZeroError toInteger (W16# x#) = smallInteger (word2Int# x#)

instance Bounded Word16 where minBound = 0 maxBound = 0xFFFF

instance Ix Word16 where range (m,n) = [m..n] unsafeIndex (m,_) i = fromIntegral (i - m) inRange (m,n) i = m <= i && i <= n

instance Bits Word16 where {-# INLINE shift #-} {-# INLINE bit #-} {-# INLINE testBit #-}

([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060194)) [.&.](Data.Bits.html#.%26.)   ([W16#](GHC.Word.html#W16%23) [y#](#local-6989586621679060195))  = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060194) `and#` [y#](#local-6989586621679060195))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060196)) [.|.](Data.Bits.html#.%7C.)   ([W16#](GHC.Word.html#W16%23) [y#](#local-6989586621679060197))  = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060196) `or#`  [y#](#local-6989586621679060197))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060198)) `[xor](Data.Bits.html#xor)` ([W16#](GHC.Word.html#W16%23) [y#](#local-6989586621679060199))  = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060198) `xor#` [y#](#local-6989586621679060199))
[complement](Data.Bits.html#complement) ([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060200))       = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060200) `xor#` [mb#](#local-6989586621679060201))
    where !([W16#](GHC.Word.html#W16%23) [mb#](#local-6989586621679060201)) = [maxBound](GHC.Enum.html#maxBound)
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060202)) `[shift](Data.Bits.html#shift)` (I# [i#](#local-6989586621679060203))
    | isTrue# ([i#](#local-6989586621679060203) >=# 0#)  = [W16#](GHC.Word.html#W16%23) (narrow16Word# ([x#](#local-6989586621679060202) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060203)))
    | [otherwise](GHC.Base.html#otherwise)            = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060202) `[shiftRL#](GHC.Base.html#shiftRL%23)` negateInt# [i#](#local-6989586621679060203))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060204)) `[shiftL](Data.Bits.html#shiftL)` (I# [i#](#local-6989586621679060205))       = [W16#](GHC.Word.html#W16%23) (narrow16Word# ([x#](#local-6989586621679060204) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060205)))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060206)) `[unsafeShiftL](Data.Bits.html#unsafeShiftL)` (I# [i#](#local-6989586621679060207)) =
    [W16#](GHC.Word.html#W16%23) (narrow16Word# ([x#](#local-6989586621679060206) `uncheckedShiftL#` [i#](#local-6989586621679060207)))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060208)) `[shiftR](Data.Bits.html#shiftR)`       (I# [i#](#local-6989586621679060209)) = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060208) `[shiftRL#](GHC.Base.html#shiftRL%23)` [i#](#local-6989586621679060209))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060210)) `[unsafeShiftR](Data.Bits.html#unsafeShiftR)` (I# [i#](#local-6989586621679060211)) = [W16#](GHC.Word.html#W16%23) ([x#](#local-6989586621679060210) `uncheckedShiftRL#` [i#](#local-6989586621679060211))
([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060212)) `[rotate](Data.Bits.html#rotate)`       (I# [i#](#local-6989586621679060213))
    | isTrue# ([i'#](#local-6989586621679060214) ==# 0#) = [W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060212)
    | [otherwise](GHC.Base.html#otherwise)  = [W16#](GHC.Word.html#W16%23) (narrow16Word# (([x#](#local-6989586621679060212) `uncheckedShiftL#` [i'#](#local-6989586621679060214)) `or#`
                                        ([x#](#local-6989586621679060212) `uncheckedShiftRL#` (16# -# [i'#](#local-6989586621679060214)))))
    where
    ![i'#](#local-6989586621679060214) = word2Int# (int2Word# [i#](#local-6989586621679060213) `and#` 15##)
[bitSizeMaybe](Data.Bits.html#bitSizeMaybe) [i](#local-6989586621679060215)            = [Just](GHC.Maybe.html#Just) ([finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060215))
[bitSize](Data.Bits.html#bitSize) [i](#local-6989586621679060216)                 = [finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060216)
[isSigned](Data.Bits.html#isSigned) _                = False
[popCount](Data.Bits.html#popCount) ([W16#](GHC.Word.html#W16%23) [x#](#local-6989586621679060217))        = I# (word2Int# (popCnt16# [x#](#local-6989586621679060217)))
[bit](Data.Bits.html#bit)                       = [bitDefault](Data.Bits.html#bitDefault)
[testBit](Data.Bits.html#testBit)                   = [testBitDefault](Data.Bits.html#testBitDefault)

instance FiniteBits Word16 where finiteBitSize _ = 16 countLeadingZeros (W16# x#) = I# (word2Int# (clz16# x#)) countTrailingZeros (W16# x#) = I# (word2Int# (ctz16# x#))

byteSwap16 :: Word16 -> Word16 byteSwap16 (W16# w#) = W16# (narrow16Word# (byteSwap16# w#))

{-# RULES "fromIntegral/Word8->Word16" fromIntegral = (W8# x#) -> W16# 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# (narrow16Word# x#) "fromIntegral/Word16->a" fromIntegral = (W16# x#) -> fromIntegral (W# x#) #-}

{-# RULES "properFraction/Float->(Word16,Float)" properFraction = \x -> case properFraction x of { (n, y) -> ((fromIntegral :: Int -> Word16) n, y :: Float) } "truncate/Float->Word16" truncate = (fromIntegral :: Int -> Word16) . (truncate :: Float -> Int) "floor/Float->Word16" floor = (fromIntegral :: Int -> Word16) . (floor :: Float -> Int) "ceiling/Float->Word16" ceiling = (fromIntegral :: Int -> Word16) . (ceiling :: Float -> Int) "round/Float->Word16" round = (fromIntegral :: Int -> Word16) . (round :: Float -> Int) #-}

{-# RULES "properFraction/Double->(Word16,Double)" properFraction = \x -> case properFraction x of { (n, y) -> ((fromIntegral :: Int -> Word16) n, y :: Double) } "truncate/Double->Word16" truncate = (fromIntegral :: Int -> Word16) . (truncate :: Double -> Int) "floor/Double->Word16" floor = (fromIntegral :: Int -> Word16) . (floor :: Double -> Int) "ceiling/Double->Word16" ceiling = (fromIntegral :: Int -> Word16) . (ceiling :: Double -> Int) "round/Double->Word16" round = (fromIntegral :: Int -> Word16) . (round :: Double -> Int) #-}

#if WORD_SIZE_IN_BITS > 32

{-# RULES "properFraction/Float->(Word32,Float)" properFraction = \x -> case properFraction x of { (n, y) -> ((fromIntegral :: Int -> Word32) n, y :: Float) } "truncate/Float->Word32" truncate = (fromIntegral :: Int -> Word32) . (truncate :: Float -> Int) "floor/Float->Word32" floor = (fromIntegral :: Int -> Word32) . (floor :: Float -> Int) "ceiling/Float->Word32" ceiling = (fromIntegral :: Int -> Word32) . (ceiling :: Float -> Int) "round/Float->Word32" round = (fromIntegral :: Int -> Word32) . (round :: Float -> Int) #-}

{-# RULES "properFraction/Double->(Word32,Double)" properFraction = \x -> case properFraction x of { (n, y) -> ((fromIntegral :: Int -> Word32) n, y :: Double) } "truncate/Double->Word32" truncate = (fromIntegral :: Int -> Word32) . (truncate :: Double -> Int) "floor/Double->Word32" floor = (fromIntegral :: Int -> Word32) . (floor :: Double -> Int) "ceiling/Double->Word32" ceiling = (fromIntegral :: Int -> Word32) . (ceiling :: Double -> Int) "round/Double->Word32" round = (fromIntegral :: Int -> Word32) . (round :: Double -> Int) #-}

#endif

data {-# CTYPE "HsWord32" #-} Word32 = W32# Word#

instance Eq Word32 where (==) = eqWord32 (/=) = neWord32

eqWord32, neWord32 :: Word32 -> Word32 -> Bool eqWord32 (W32# x) (W32# y) = isTrue# (x eqWord# y) neWord32 (W32# x) (W32# y) = isTrue# (x neWord# y) {-# INLINE [1] eqWord32 #-} {-# INLINE [1] neWord32 #-}

instance Ord Word32 where (<) = ltWord32 (<=) = leWord32 (>=) = geWord32 (>) = gtWord32

{-# INLINE [1] gtWord32 #-} {-# INLINE [1] geWord32 #-} {-# INLINE [1] ltWord32 #-} {-# INLINE [1] leWord32 #-} gtWord32, geWord32, ltWord32, leWord32 :: Word32 -> Word32 -> Bool (W32# x) [gtWord32](GHC.Word.html#gtWord32) (W32# y) = isTrue# (x gtWord# y) (W32# x) [geWord32](GHC.Word.html#geWord32) (W32# y) = isTrue# (x geWord# y) (W32# x) [ltWord32](GHC.Word.html#ltWord32) (W32# y) = isTrue# (x ltWord# y) (W32# x) [leWord32](GHC.Word.html#leWord32) (W32# y) = isTrue# (x leWord# y)

instance Num Word32 where (W32# x#) + (W32# y#) = W32# (narrow32Word# (x# plusWord# y#)) (W32# x#) - (W32# y#) = W32# (narrow32Word# (x# minusWord# y#)) (W32# x#) * (W32# y#) = W32# (narrow32Word# (x# timesWord# y#)) negate (W32# x#) = W32# (narrow32Word# (int2Word# (negateInt# (word2Int# x#)))) abs x = x signum 0 = 0 signum _ = 1 fromInteger i = W32# (narrow32Word# (integerToWord i))

instance Enum Word32 where succ x | x /= maxBound = x + 1 | otherwise = succError "Word32" pred x | x /= minBound = x - 1 | otherwise = predError "Word32" toEnum i@(I# i#) | i >= 0 #if WORD_SIZE_IN_BITS > 32 && i <= fromIntegral (maxBound::Word32) #endif = W32# (int2Word# i#) | otherwise = toEnumError "Word32" i (minBound::Word32, maxBound::Word32) #if WORD_SIZE_IN_BITS == 32 fromEnum x@(W32# x#) | x <= fromIntegral (maxBound::Int) = I# (word2Int# x#) | otherwise = fromEnumError "Word32" x enumFrom = integralEnumFrom enumFromThen = integralEnumFromThen enumFromTo = integralEnumFromTo enumFromThenTo = integralEnumFromThenTo #else fromEnum (W32# x#) = I# (word2Int# x#) enumFrom = boundedEnumFrom enumFromThen = boundedEnumFromThen #endif

instance Integral Word32 where quot (W32# x#) y@(W32# y#) | y /= 0 = W32# (x# quotWord# y#) | otherwise = divZeroError rem (W32# x#) y@(W32# y#) | y /= 0 = W32# (x# remWord# y#) | otherwise = divZeroError div (W32# x#) y@(W32# y#) | y /= 0 = W32# (x# quotWord# y#) | otherwise = divZeroError mod (W32# x#) y@(W32# y#) | y /= 0 = W32# (x# remWord# y#) | otherwise = divZeroError quotRem (W32# x#) y@(W32# y#) | y /= 0 = case x# quotRemWord# y# of (# q, r #) -> (W32# q, W32# r) | otherwise = divZeroError divMod (W32# x#) y@(W32# y#) | y /= 0 = (W32# (x# quotWord# y#), W32# (x# remWord# y#)) | otherwise = divZeroError toInteger (W32# x#) #if WORD_SIZE_IN_BITS == 32 | isTrue# (i# >=# 0#) = smallInteger i# | otherwise = wordToInteger x# where !i# = word2Int# x# #else = smallInteger (word2Int# x#) #endif

instance Bits Word32 where {-# INLINE shift #-} {-# INLINE bit #-} {-# INLINE testBit #-}

([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060133)) [.&.](Data.Bits.html#.%26.)   ([W32#](GHC.Word.html#W32%23) [y#](#local-6989586621679060134))  = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060133) `and#` [y#](#local-6989586621679060134))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060135)) [.|.](Data.Bits.html#.%7C.)   ([W32#](GHC.Word.html#W32%23) [y#](#local-6989586621679060136))  = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060135) `or#`  [y#](#local-6989586621679060136))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060137)) `[xor](Data.Bits.html#xor)` ([W32#](GHC.Word.html#W32%23) [y#](#local-6989586621679060138))  = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060137) `xor#` [y#](#local-6989586621679060138))
[complement](Data.Bits.html#complement) ([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060139))       = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060139) `xor#` [mb#](#local-6989586621679060140))
    where !([W32#](GHC.Word.html#W32%23) [mb#](#local-6989586621679060140)) = [maxBound](GHC.Enum.html#maxBound)
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060141)) `[shift](Data.Bits.html#shift)` (I# [i#](#local-6989586621679060142))
    | isTrue# ([i#](#local-6989586621679060142) >=# 0#)  = [W32#](GHC.Word.html#W32%23) (narrow32Word# ([x#](#local-6989586621679060141) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060142)))
    | [otherwise](GHC.Base.html#otherwise)            = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060141) `[shiftRL#](GHC.Base.html#shiftRL%23)` negateInt# [i#](#local-6989586621679060142))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060143)) `[shiftL](Data.Bits.html#shiftL)`       (I# [i#](#local-6989586621679060144)) = [W32#](GHC.Word.html#W32%23) (narrow32Word# ([x#](#local-6989586621679060143) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060144)))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060145)) `[unsafeShiftL](Data.Bits.html#unsafeShiftL)` (I# [i#](#local-6989586621679060146)) =
    [W32#](GHC.Word.html#W32%23) (narrow32Word# ([x#](#local-6989586621679060145) `uncheckedShiftL#` [i#](#local-6989586621679060146)))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060147)) `[shiftR](Data.Bits.html#shiftR)`       (I# [i#](#local-6989586621679060148)) = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060147) `[shiftRL#](GHC.Base.html#shiftRL%23)` [i#](#local-6989586621679060148))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060149)) `[unsafeShiftR](Data.Bits.html#unsafeShiftR)` (I# [i#](#local-6989586621679060150)) = [W32#](GHC.Word.html#W32%23) ([x#](#local-6989586621679060149) `uncheckedShiftRL#` [i#](#local-6989586621679060150))
([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060151)) `[rotate](Data.Bits.html#rotate)`       (I# [i#](#local-6989586621679060152))
    | isTrue# ([i'#](#local-6989586621679060153) ==# 0#) = [W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060151)
    | [otherwise](GHC.Base.html#otherwise)   = [W32#](GHC.Word.html#W32%23) (narrow32Word# (([x#](#local-6989586621679060151) `uncheckedShiftL#` [i'#](#local-6989586621679060153)) `or#`
                                        ([x#](#local-6989586621679060151) `uncheckedShiftRL#` (32# -# [i'#](#local-6989586621679060153)))))
    where
    ![i'#](#local-6989586621679060153) = word2Int# (int2Word# [i#](#local-6989586621679060152) `and#` 31##)
[bitSizeMaybe](Data.Bits.html#bitSizeMaybe) [i](#local-6989586621679060154)            = [Just](GHC.Maybe.html#Just) ([finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060154))
[bitSize](Data.Bits.html#bitSize) [i](#local-6989586621679060155)                 = [finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060155)
[isSigned](Data.Bits.html#isSigned) _                = False
[popCount](Data.Bits.html#popCount) ([W32#](GHC.Word.html#W32%23) [x#](#local-6989586621679060156))        = I# (word2Int# (popCnt32# [x#](#local-6989586621679060156)))
[bit](Data.Bits.html#bit)                       = [bitDefault](Data.Bits.html#bitDefault)
[testBit](Data.Bits.html#testBit)                   = [testBitDefault](Data.Bits.html#testBitDefault)

instance FiniteBits Word32 where finiteBitSize _ = 32 countLeadingZeros (W32# x#) = I# (word2Int# (clz32# x#)) countTrailingZeros (W32# x#) = I# (word2Int# (ctz32# x#))

{-# RULES "fromIntegral/Word8->Word32" fromIntegral = (W8# x#) -> W32# x# "fromIntegral/Word16->Word32" fromIntegral = (W16# x#) -> W32# 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# (narrow32Word# x#) "fromIntegral/Word32->a" fromIntegral = (W32# x#) -> fromIntegral (W# x#) #-}

instance Show Word32 where #if WORD_SIZE_IN_BITS < 33 showsPrec p x = showsPrec p (toInteger x) #else showsPrec p x = showsPrec p (fromIntegral x :: Int) #endif

instance Real Word32 where toRational x = toInteger x % 1

instance Bounded Word32 where minBound = 0 maxBound = 0xFFFFFFFF

instance Ix Word32 where range (m,n) = [m..n] unsafeIndex (m,_) i = fromIntegral (i - m) inRange (m,n) i = m <= i && i <= n

byteSwap32 :: Word32 -> Word32 byteSwap32 (W32# w#) = W32# (narrow32Word# (byteSwap32# w#))

#if WORD_SIZE_IN_BITS < 64

data {-# CTYPE "HsWord64" #-} Word64 = W64# Word64#

instance Eq Word64 where (==) = eqWord64 (/=) = neWord64

eqWord64, neWord64 :: Word64 -> Word64 -> Bool eqWord64 (W64# x) (W64# y) = isTrue# (x eqWord64# y) neWord64 (W64# x) (W64# y) = isTrue# (x neWord64# y) {-# INLINE [1] eqWord64 #-} {-# INLINE [1] neWord64 #-}

instance Ord Word64 where (<) = ltWord64 (<=) = leWord64 (>=) = geWord64 (>) = gtWord64

{-# INLINE [1] gtWord64 #-} {-# INLINE [1] geWord64 #-} {-# INLINE [1] ltWord64 #-} {-# INLINE [1] leWord64 #-} gtWord64, geWord64, ltWord64, leWord64 :: Word64 -> Word64 -> Bool (W64# x) gtWord64 (W64# y) = isTrue# (x gtWord64# y) (W64# x) geWord64 (W64# y) = isTrue# (x geWord64# y) (W64# x) ltWord64 (W64# y) = isTrue# (x ltWord64# y) (W64# x) leWord64 (W64# y) = isTrue# (x leWord64# y)

instance Num Word64 where (W64# x#) + (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# plusInt64# word64ToInt64# y#)) (W64# x#) - (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# minusInt64# word64ToInt64# y#)) (W64# x#) * (W64# y#) = W64# (int64ToWord64# (word64ToInt64# x# timesInt64# word64ToInt64# y#)) negate (W64# x#) = W64# (int64ToWord64# (negateInt64# (word64ToInt64# x#))) abs x = x signum 0 = 0 signum _ = 1 fromInteger i = W64# (integerToWord64 i)

instance Enum Word64 where succ x | x /= maxBound = x + 1 | otherwise = succError "Word64" pred x | x /= minBound = x - 1 | otherwise = predError "Word64" toEnum i@(I# i#) | i >= 0 = W64# (wordToWord64# (int2Word# i#)) | otherwise = toEnumError "Word64" i (minBound::Word64, maxBound::Word64) fromEnum x@(W64# x#) | x <= fromIntegral (maxBound::Int) = I# (word2Int# (word64ToWord# x#)) | otherwise = fromEnumError "Word64" x enumFrom = integralEnumFrom enumFromThen = integralEnumFromThen enumFromTo = integralEnumFromTo enumFromThenTo = integralEnumFromThenTo

instance Integral Word64 where quot (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# quotWord64# y#) | otherwise = divZeroError rem (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# remWord64# y#) | otherwise = divZeroError div (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# quotWord64# y#) | otherwise = divZeroError mod (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# remWord64# y#) | otherwise = divZeroError quotRem (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# quotWord64# y#), W64# (x# remWord64# y#)) | otherwise = divZeroError divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# quotWord64# y#), W64# (x# remWord64# y#)) | otherwise = divZeroError toInteger (W64# x#) = word64ToInteger x#

instance Bits Word64 where {-# INLINE shift #-} {-# INLINE bit #-} {-# INLINE testBit #-}

(W64# x#) .&.   (W64# y#)  = W64# (x# `and64#` y#)
(W64# x#) .|.   (W64# y#)  = W64# (x# `or64#`  y#)
(W64# x#) `xor` (W64# y#)  = W64# (x# `xor64#` y#)
complement (W64# x#)       = W64# (not64# x#)
(W64# x#) `shift` (I# i#)
    | isTrue# (i# >=# 0#)  = W64# (x# `shiftL64#` i#)
    | otherwise            = W64# (x# `shiftRL64#` negateInt# i#)
(W64# x#) `shiftL`       (I# i#) = W64# (x# `shiftL64#` i#)
(W64# x#) `unsafeShiftL` (I# i#) = W64# (x# `uncheckedShiftL64#` i#)
(W64# x#) `shiftR`       (I# i#) = W64# (x# `shiftRL64#` i#)
(W64# x#) `unsafeShiftR` (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)
(W64# x#) `rotate` (I# i#)
    | isTrue# (i'# ==# 0#) = W64# x#
    | otherwise            = W64# ((x# `uncheckedShiftL64#` i'#) `or64#`
                                   (x# `uncheckedShiftRL64#` (64# -# i'#)))
    where
    !i'# = word2Int# (int2Word# i# `and#` 63##)
bitSizeMaybe i            = Just (finiteBitSize i)
bitSize i                 = finiteBitSize i
isSigned _                = False
popCount (W64# x#)        = I# (word2Int# (popCnt64# x#))
bit                       = bitDefault
testBit                   = testBitDefault

shiftL64#, shiftRL64# :: Word64# -> Int# -> Word64#

a shiftL64# b | isTrue# (b >=# 64#) = wordToWord64# 0## | otherwise = a uncheckedShiftL64# b

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

data {-# CTYPE "HsWord64" #-} Word64 = W64# Word#

instance Eq Word64 where (==) = eqWord64 (/=) = neWord64

eqWord64, neWord64 :: Word64 -> Word64 -> Bool eqWord64 (W64# x) (W64# y) = isTrue# (x eqWord# y) neWord64 (W64# x) (W64# y) = isTrue# (x neWord# y) {-# INLINE [1] eqWord64 #-} {-# INLINE [1] neWord64 #-}

instance Ord Word64 where (<) = ltWord64 (<=) = leWord64 (>=) = geWord64 (>) = gtWord64

{-# INLINE [1] gtWord64 #-} {-# INLINE [1] geWord64 #-} {-# INLINE [1] ltWord64 #-} {-# INLINE [1] leWord64 #-} gtWord64, geWord64, ltWord64, leWord64 :: Word64 -> Word64 -> Bool (W64# x) [gtWord64](GHC.Word.html#gtWord64) (W64# y) = isTrue# (x gtWord# y) (W64# x) [geWord64](GHC.Word.html#geWord64) (W64# y) = isTrue# (x geWord# y) (W64# x) [ltWord64](GHC.Word.html#ltWord64) (W64# y) = isTrue# (x ltWord# y) (W64# x) [leWord64](GHC.Word.html#leWord64) (W64# y) = isTrue# (x leWord# y)

instance Num Word64 where (W64# x#) + (W64# y#) = W64# (x# plusWord# y#) (W64# x#) - (W64# y#) = W64# (x# minusWord# y#) (W64# x#) * (W64# y#) = W64# (x# timesWord# y#) negate (W64# x#) = W64# (int2Word# (negateInt# (word2Int# x#))) abs x = x signum 0 = 0 signum _ = 1 fromInteger i = W64# (integerToWord i)

instance Enum Word64 where succ x | x /= maxBound = x + 1 | otherwise = succError "Word64" pred x | x /= minBound = x - 1 | otherwise = predError "Word64" toEnum i@(I# i#) | i >= 0 = W64# (int2Word# i#) | otherwise = toEnumError "Word64" i (minBound::Word64, maxBound::Word64) fromEnum x@(W64# x#) | x <= fromIntegral (maxBound::Int) = I# (word2Int# x#) | otherwise = fromEnumError "Word64" x enumFrom = integralEnumFrom enumFromThen = integralEnumFromThen enumFromTo = integralEnumFromTo enumFromThenTo = integralEnumFromThenTo

instance Integral Word64 where quot (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# quotWord# y#) | otherwise = divZeroError rem (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# remWord# y#) | otherwise = divZeroError div (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# quotWord# y#) | otherwise = divZeroError mod (W64# x#) y@(W64# y#) | y /= 0 = W64# (x# remWord# y#) | otherwise = divZeroError quotRem (W64# x#) y@(W64# y#) | y /= 0 = case x# quotRemWord# y# of (# q, r #) -> (W64# q, W64# r) | otherwise = divZeroError divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# quotWord# y#), W64# (x# remWord# y#)) | otherwise = divZeroError toInteger (W64# x#) | isTrue# (i# >=# 0#) = smallInteger i# | otherwise = wordToInteger x# where i# = word2Int# x#

instance Bits Word64 where {-# INLINE shift #-} {-# INLINE bit #-} {-# INLINE testBit #-}

([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060060)) [.&.](Data.Bits.html#.%26.)   ([W64#](GHC.Word.html#W64%23) [y#](#local-6989586621679060061))  = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060060) `and#` [y#](#local-6989586621679060061))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060062)) [.|.](Data.Bits.html#.%7C.)   ([W64#](GHC.Word.html#W64%23) [y#](#local-6989586621679060063))  = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060062) `or#`  [y#](#local-6989586621679060063))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060064)) `[xor](Data.Bits.html#xor)` ([W64#](GHC.Word.html#W64%23) [y#](#local-6989586621679060065))  = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060064) `xor#` [y#](#local-6989586621679060065))
[complement](Data.Bits.html#complement) ([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060066))       = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060066) `xor#` [mb#](#local-6989586621679060067))
    where !([W64#](GHC.Word.html#W64%23) [mb#](#local-6989586621679060067)) = [maxBound](GHC.Enum.html#maxBound)
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060068)) `[shift](Data.Bits.html#shift)` (I# [i#](#local-6989586621679060069))
    | isTrue# ([i#](#local-6989586621679060069) >=# 0#)  = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060068) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060069))
    | [otherwise](GHC.Base.html#otherwise)            = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060068) `[shiftRL#](GHC.Base.html#shiftRL%23)` negateInt# [i#](#local-6989586621679060069))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060070)) `[shiftL](Data.Bits.html#shiftL)`       (I# [i#](#local-6989586621679060071)) = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060070) `[shiftL#](GHC.Base.html#shiftL%23)` [i#](#local-6989586621679060071))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060072)) `[unsafeShiftL](Data.Bits.html#unsafeShiftL)` (I# [i#](#local-6989586621679060073)) = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060072) `uncheckedShiftL#` [i#](#local-6989586621679060073))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060074)) `[shiftR](Data.Bits.html#shiftR)`       (I# [i#](#local-6989586621679060075)) = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060074) `[shiftRL#](GHC.Base.html#shiftRL%23)` [i#](#local-6989586621679060075))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060076)) `[unsafeShiftR](Data.Bits.html#unsafeShiftR)` (I# [i#](#local-6989586621679060077)) = [W64#](GHC.Word.html#W64%23) ([x#](#local-6989586621679060076) `uncheckedShiftRL#` [i#](#local-6989586621679060077))
([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060078)) `[rotate](Data.Bits.html#rotate)` (I# [i#](#local-6989586621679060079))
    | isTrue# ([i'#](#local-6989586621679060080) ==# 0#) = [W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060078)
    | [otherwise](GHC.Base.html#otherwise)            = [W64#](GHC.Word.html#W64%23) (([x#](#local-6989586621679060078) `uncheckedShiftL#` [i'#](#local-6989586621679060080)) `or#`
                                   ([x#](#local-6989586621679060078) `uncheckedShiftRL#` (64# -# [i'#](#local-6989586621679060080))))
    where
    ![i'#](#local-6989586621679060080) = word2Int# (int2Word# [i#](#local-6989586621679060079) `and#` 63##)
[bitSizeMaybe](Data.Bits.html#bitSizeMaybe) [i](#local-6989586621679060081)            = [Just](GHC.Maybe.html#Just) ([finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060081))
[bitSize](Data.Bits.html#bitSize) [i](#local-6989586621679060082)                 = [finiteBitSize](Data.Bits.html#finiteBitSize) [i](#local-6989586621679060082)
[isSigned](Data.Bits.html#isSigned) _                = False
[popCount](Data.Bits.html#popCount) ([W64#](GHC.Word.html#W64%23) [x#](#local-6989586621679060083))        = I# (word2Int# (popCnt64# [x#](#local-6989586621679060083)))
[bit](Data.Bits.html#bit)                       = [bitDefault](Data.Bits.html#bitDefault)
[testBit](Data.Bits.html#testBit)                   = [testBitDefault](Data.Bits.html#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#

uncheckedShiftRL64# :: Word# -> Int# -> Word# uncheckedShiftRL64# = uncheckedShiftRL#

#endif

instance FiniteBits Word64 where finiteBitSize _ = 64 countLeadingZeros (W64# x#) = I# (word2Int# (clz64# x#)) countTrailingZeros (W64# x#) = I# (word2Int# (ctz64# x#))

instance Show Word64 where showsPrec p x = showsPrec p (toInteger x)

instance Real Word64 where toRational x = toInteger x % 1

instance Bounded Word64 where minBound = 0 maxBound = 0xFFFFFFFFFFFFFFFF

instance Ix Word64 where range (m,n) = [m..n] unsafeIndex (m,_) i = fromIntegral (i - m) inRange (m,n) i = m <= i && i <= n

#if WORD_SIZE_IN_BITS < 64 byteSwap64 :: Word64 -> Word64 byteSwap64 (W64# w#) = W64# (byteSwap64# w#) #else byteSwap64 :: Word64 -> Word64 byteSwap64 (W64# w#) = W64# (byteSwap# w#) #endif

{-# 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 = wordToNatural . (fromIntegral :: Word8 -> Word) "fromIntegral/Word16->Natural" fromIntegral = wordToNatural . (fromIntegral :: Word16 -> Word) "fromIntegral/Word32->Natural" fromIntegral = wordToNatural . (fromIntegral :: Word32 -> Word) #-}

#if WORD_SIZE_IN_BITS == 64

{-# RULES "fromIntegral/Natural->Word64" fromIntegral = (fromIntegral :: Word -> Word64) . naturalToWord "fromIntegral/Word64->Natural" fromIntegral = wordToNatural . (fromIntegral :: Word64 -> Word) #-} #endif