This module provides unsigned integer types of unspecified width (Word) and fixed widths (Word8, Word16, Word32 and Word64). All arithmetic is performed modulo 2^n, where n is the number of bits in the type.
For coercing between any two integer types, use fromIntegral. Coercing word types to and from integer types preserves representation, not sign.
The rules that hold for Enum instances over a bounded type such as Int (see the section of the Haskell language report dealing with arithmetic sequences) also hold for the Enum instances over the various Word types defined here.
Right and left shifts by amounts greater than or equal to the width of the type result in a zero result. This is contrary to the behaviour in C, which is undefined; a common interpretation is to truncate the shift count to the width of the type, for example 1 << 32 == 1 in some C implementations.
data Word |
instance Bounded Word |
instance Enum Word |
instance Eq Word |
instance Integral Word |
instance Num Word |
instance Ord Word |
instance Read Word |
instance Real Word |
instance Show Word |
instance Ix Word |
instance Storable Word |
instance Bits Word |
data Word8 |
instance Bounded Word8 |
instance Enum Word8 |
instance Eq Word8 |
instance Integral Word8 |
instance Num Word8 |
instance Ord Word8 |
instance Read Word8 |
instance Real Word8 |
instance Show Word8 |
instance Ix Word8 |
instance Storable Word8 |
instance Bits Word8 |
data Word16 |
instance Bounded Word16 |
instance Enum Word16 |
instance Eq Word16 |
instance Integral Word16 |
instance Num Word16 |
instance Ord Word16 |
instance Read Word16 |
instance Real Word16 |
instance Show Word16 |
instance Ix Word16 |
instance Storable Word16 |
instance Bits Word16 |
data Word32 |
instance Bounded Word32 |
instance Enum Word32 |
instance Eq Word32 |
instance Integral Word32 |
instance Num Word32 |
instance Ord Word32 |
instance Read Word32 |
instance Real Word32 |
instance Show Word32 |
instance Ix Word32 |
instance Storable Word32 |
instance Bits Word32 |
data Word64 |
instance Bounded Word64 |
instance Enum Word64 |
instance Eq Word64 |
instance Integral Word64 |
instance Num Word64 |
instance Ord Word64 |
instance Read Word64 |
instance Real Word64 |
instance Show Word64 |
instance Ix Word64 |
instance Storable Word64 |
instance Bits Word64 |