Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Unsigned integer types.
Synopsis
- data Word
- data Word8
- data Word16
- data Word32
- data Word64
- byteSwap16 :: Word16 -> Word16
- byteSwap32 :: Word32 -> Word32
- byteSwap64 :: Word64 -> Word64
Unsigned integral types
Instances
Bounded Word # | Since: base-2.1 |
Enum Word # | Since: base-2.1 |
Eq Word | |
Integral Word # | Since: base-2.1 |
Data Word # | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word -> c Word # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word # dataTypeOf :: Word -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word) # gmapT :: (forall b. Data b => b -> b) -> Word -> Word # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r # gmapQ :: (forall d. Data d => d -> u) -> Word -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word -> m Word # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word # | |
Num Word # | Since: base-2.1 |
Ord Word | |
Read Word # | Since: base-4.5.0.0 |
Real Word # | Since: base-2.1 |
Defined in GHC.Real toRational :: Word -> Rational # | |
Show Word # | Since: base-2.1 |
Ix Word # | Since: base-4.6.0.0 |
FiniteBits Word # | Since: base-4.6.0.0 |
Defined in Data.Bits | |
Bits Word # | Since: base-2.1 |
Defined in Data.Bits (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # bitSizeMaybe :: Word -> Maybe Int # shiftL :: Word -> Int -> Word # unsafeShiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # unsafeShiftR :: Word -> Int -> Word # rotateL :: Word -> Int -> Word # | |
Storable Word # | Since: base-2.1 |
Defined in Foreign.Storable | |
PrintfArg Word # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Word -> FieldFormatter # parseFormat :: Word -> ModifierParser # | |
Generic1 (URec Word :: k -> Type) # | |
Functor (URec Word :: Type -> Type) # | Since: base-4.9.0.0 |
Foldable (URec Word :: Type -> Type) # | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Word m -> m # foldMap :: Monoid m => (a -> m) -> URec Word a -> m # foldr :: (a -> b -> b) -> b -> URec Word a -> b # foldr' :: (a -> b -> b) -> b -> URec Word a -> b # foldl :: (b -> a -> b) -> b -> URec Word a -> b # foldl' :: (b -> a -> b) -> b -> URec Word a -> b # foldr1 :: (a -> a -> a) -> URec Word a -> a # foldl1 :: (a -> a -> a) -> URec Word a -> a # toList :: URec Word a -> [a] # length :: URec Word a -> Int # elem :: Eq a => a -> URec Word a -> Bool # maximum :: Ord a => URec Word a -> a # minimum :: Ord a => URec Word a -> a # | |
Traversable (URec Word :: Type -> Type) # | Since: base-4.9.0.0 |
Eq (URec Word p) # | Since: base-4.9.0.0 |
Ord (URec Word p) # | Since: base-4.9.0.0 |
Defined in GHC.Generics compare :: URec Word p -> URec Word p -> Ordering Source # (<) :: URec Word p -> URec Word p -> Bool Source # (<=) :: URec Word p -> URec Word p -> Bool Source # (>) :: URec Word p -> URec Word p -> Bool Source # (>=) :: URec Word p -> URec Word p -> Bool Source # | |
Show (URec Word p) # | Since: base-4.9.0.0 |
Generic (URec Word p) # | |
data URec Word (p :: k) # | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Word :: k -> Type) # | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Word p) # | Since: base-4.9.0.0 |
Defined in GHC.Generics |
8-bit unsigned integer type
Instances
Bounded Word8 # | Since: base-2.1 |
Enum Word8 # | Since: base-2.1 |
Eq Word8 # | Since: base-2.1 |
Integral Word8 # | Since: base-2.1 |
Data Word8 # | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word8 -> c Word8 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word8 # dataTypeOf :: Word8 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word8) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word8) # gmapT :: (forall b. Data b => b -> b) -> Word8 -> Word8 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word8 -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word8 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word8 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word8 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # | |
Num Word8 # | Since: base-2.1 |
Ord Word8 # | Since: base-2.1 |
Read Word8 # | Since: base-2.1 |
Real Word8 # | Since: base-2.1 |
Defined in GHC.Word toRational :: Word8 -> Rational # | |
Show Word8 # | Since: base-2.1 |
Ix Word8 # | Since: base-2.1 |
FiniteBits Word8 # | Since: base-4.6.0.0 |
Defined in GHC.Word finiteBitSize :: Word8 -> Int # countLeadingZeros :: Word8 -> Int # countTrailingZeros :: Word8 -> Int # | |
Bits Word8 # | Since: base-2.1 |
Defined in GHC.Word (.&.) :: Word8 -> Word8 -> Word8 # (.|.) :: Word8 -> Word8 -> Word8 # xor :: Word8 -> Word8 -> Word8 # complement :: Word8 -> Word8 # shift :: Word8 -> Int -> Word8 # rotate :: Word8 -> Int -> Word8 # setBit :: Word8 -> Int -> Word8 # clearBit :: Word8 -> Int -> Word8 # complementBit :: Word8 -> Int -> Word8 # testBit :: Word8 -> Int -> Bool # bitSizeMaybe :: Word8 -> Maybe Int # shiftL :: Word8 -> Int -> Word8 # unsafeShiftL :: Word8 -> Int -> Word8 # shiftR :: Word8 -> Int -> Word8 # unsafeShiftR :: Word8 -> Int -> Word8 # rotateL :: Word8 -> Int -> Word8 # | |
Storable Word8 # | Since: base-2.1 |
PrintfArg Word8 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Word8 -> FieldFormatter # parseFormat :: Word8 -> ModifierParser # |
16-bit unsigned integer type
Instances
Bounded Word16 # | Since: base-2.1 |
Enum Word16 # | Since: base-2.1 |
Defined in GHC.Word | |
Eq Word16 # | Since: base-2.1 |
Integral Word16 # | Since: base-2.1 |
Data Word16 # | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word16 -> c Word16 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word16 # toConstr :: Word16 -> Constr # dataTypeOf :: Word16 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word16) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word16) # gmapT :: (forall b. Data b => b -> b) -> Word16 -> Word16 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word16 -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word16 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word16 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word16 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word16 -> m Word16 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word16 -> m Word16 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word16 -> m Word16 # | |
Num Word16 # | Since: base-2.1 |
Ord Word16 # | Since: base-2.1 |
Defined in GHC.Word | |
Read Word16 # | Since: base-2.1 |
Real Word16 # | Since: base-2.1 |
Defined in GHC.Word toRational :: Word16 -> Rational # | |
Show Word16 # | Since: base-2.1 |
Ix Word16 # | Since: base-2.1 |
FiniteBits Word16 # | Since: base-4.6.0.0 |
Defined in GHC.Word finiteBitSize :: Word16 -> Int # countLeadingZeros :: Word16 -> Int # countTrailingZeros :: Word16 -> Int # | |
Bits Word16 # | Since: base-2.1 |
Defined in GHC.Word (.&.) :: Word16 -> Word16 -> Word16 # (.|.) :: Word16 -> Word16 -> Word16 # xor :: Word16 -> Word16 -> Word16 # complement :: Word16 -> Word16 # shift :: Word16 -> Int -> Word16 # rotate :: Word16 -> Int -> Word16 # setBit :: Word16 -> Int -> Word16 # clearBit :: Word16 -> Int -> Word16 # complementBit :: Word16 -> Int -> Word16 # testBit :: Word16 -> Int -> Bool # bitSizeMaybe :: Word16 -> Maybe Int # shiftL :: Word16 -> Int -> Word16 # unsafeShiftL :: Word16 -> Int -> Word16 # shiftR :: Word16 -> Int -> Word16 # unsafeShiftR :: Word16 -> Int -> Word16 # rotateL :: Word16 -> Int -> Word16 # | |
Storable Word16 # | Since: base-2.1 |
PrintfArg Word16 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Word16 -> FieldFormatter # parseFormat :: Word16 -> ModifierParser # |
32-bit unsigned integer type
Instances
Bounded Word32 # | Since: base-2.1 |
Enum Word32 # | Since: base-2.1 |
Defined in GHC.Word | |
Eq Word32 # | Since: base-2.1 |
Integral Word32 # | Since: base-2.1 |
Data Word32 # | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word32 -> c Word32 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word32 # toConstr :: Word32 -> Constr # dataTypeOf :: Word32 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word32) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word32) # gmapT :: (forall b. Data b => b -> b) -> Word32 -> Word32 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word32 -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word32 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word32 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word32 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word32 -> m Word32 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word32 -> m Word32 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word32 -> m Word32 # | |
Num Word32 # | Since: base-2.1 |
Ord Word32 # | Since: base-2.1 |
Defined in GHC.Word | |
Read Word32 # | Since: base-2.1 |
Real Word32 # | Since: base-2.1 |
Defined in GHC.Word toRational :: Word32 -> Rational # | |
Show Word32 # | Since: base-2.1 |
Ix Word32 # | Since: base-2.1 |
FiniteBits Word32 # | Since: base-4.6.0.0 |
Defined in GHC.Word finiteBitSize :: Word32 -> Int # countLeadingZeros :: Word32 -> Int # countTrailingZeros :: Word32 -> Int # | |
Bits Word32 # | Since: base-2.1 |
Defined in GHC.Word (.&.) :: Word32 -> Word32 -> Word32 # (.|.) :: Word32 -> Word32 -> Word32 # xor :: Word32 -> Word32 -> Word32 # complement :: Word32 -> Word32 # shift :: Word32 -> Int -> Word32 # rotate :: Word32 -> Int -> Word32 # setBit :: Word32 -> Int -> Word32 # clearBit :: Word32 -> Int -> Word32 # complementBit :: Word32 -> Int -> Word32 # testBit :: Word32 -> Int -> Bool # bitSizeMaybe :: Word32 -> Maybe Int # shiftL :: Word32 -> Int -> Word32 # unsafeShiftL :: Word32 -> Int -> Word32 # shiftR :: Word32 -> Int -> Word32 # unsafeShiftR :: Word32 -> Int -> Word32 # rotateL :: Word32 -> Int -> Word32 # | |
Storable Word32 # | Since: base-2.1 |
PrintfArg Word32 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Word32 -> FieldFormatter # parseFormat :: Word32 -> ModifierParser # |
64-bit unsigned integer type
Instances
Bounded Word64 # | Since: base-2.1 |
Enum Word64 # | Since: base-2.1 |
Defined in GHC.Word | |
Eq Word64 # | Since: base-2.1 |
Integral Word64 # | Since: base-2.1 |
Data Word64 # | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word64 -> c Word64 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word64 # toConstr :: Word64 -> Constr # dataTypeOf :: Word64 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word64) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word64) # gmapT :: (forall b. Data b => b -> b) -> Word64 -> Word64 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word64 -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word64 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word64 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word64 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word64 -> m Word64 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word64 -> m Word64 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word64 -> m Word64 # | |
Num Word64 # | Since: base-2.1 |
Ord Word64 # | Since: base-2.1 |
Defined in GHC.Word | |
Read Word64 # | Since: base-2.1 |
Real Word64 # | Since: base-2.1 |
Defined in GHC.Word toRational :: Word64 -> Rational # | |
Show Word64 # | Since: base-2.1 |
Ix Word64 # | Since: base-2.1 |
FiniteBits Word64 # | Since: base-4.6.0.0 |
Defined in GHC.Word finiteBitSize :: Word64 -> Int # countLeadingZeros :: Word64 -> Int # countTrailingZeros :: Word64 -> Int # | |
Bits Word64 # | Since: base-2.1 |
Defined in GHC.Word (.&.) :: Word64 -> Word64 -> Word64 # (.|.) :: Word64 -> Word64 -> Word64 # xor :: Word64 -> Word64 -> Word64 # complement :: Word64 -> Word64 # shift :: Word64 -> Int -> Word64 # rotate :: Word64 -> Int -> Word64 # setBit :: Word64 -> Int -> Word64 # clearBit :: Word64 -> Int -> Word64 # complementBit :: Word64 -> Int -> Word64 # testBit :: Word64 -> Int -> Bool # bitSizeMaybe :: Word64 -> Maybe Int # shiftL :: Word64 -> Int -> Word64 # unsafeShiftL :: Word64 -> Int -> Word64 # shiftR :: Word64 -> Int -> Word64 # unsafeShiftR :: Word64 -> Int -> Word64 # rotateL :: Word64 -> Int -> Word64 # | |
Storable Word64 # | Since: base-2.1 |
PrintfArg Word64 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Word64 -> FieldFormatter # parseFormat :: Word64 -> ModifierParser # |
byte swapping
byteSwap16 :: Word16 -> Word16 #
Swap bytes in Word16
.
Since: base-4.7.0.0
byteSwap32 :: Word32 -> Word32 #
Reverse order of bytes in Word32
.
Since: base-4.7.0.0
byteSwap64 :: Word64 -> Word64 #
Reverse order of bytes in Word64
.
Since: base-4.7.0.0
Notes
- All arithmetic is performed modulo 2^n, where n is the number of
bits in the type. One non-obvious consequence of this is that
negate
should not raise an error on negative arguments. - For coercing between any two integer types, use
fromIntegral
, which is specialized for all the common cases so should be fast enough. Coercing word types to and from integer types preserves representation, not sign. - An unbounded size unsigned integer type is available with
Natural
. - The rules that hold for
Enum
instances over a bounded type such asInt
(see the section of the Haskell report dealing with arithmetic sequences) also hold for theEnum
instances over the variousWord
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.