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 |
Data.Word
Description
Unsigned integer types.
Synopsis
- dataWord
- dataWord8
- dataWord16
- dataWord32
- dataWord64
- byteSwap16 :: Word16 -> Word16
- byteSwap32 :: Word32 -> Word32
- byteSwap64 :: Word64 -> Word64
- bitReverse8 :: Word8 -> Word8
- bitReverse16 :: Word16 -> Word16
- bitReverse32 :: Word32 -> Word32
- bitReverse64 :: Word64 -> Word64
Unsigned integral types
Instances
BoundedWordSource# | Since: 2.1 |
EnumWordSource# | Since: 2.1 |
Defined in GHC.Enum | |
EqWord | |
IntegralWordSource# | Since: 2.1 |
DataWordSource# | Since: 4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word -> c WordSource# gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WordSource# toConstr :: Word -> ConstrSource# dataTypeOf :: Word -> DataTypeSource# dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word) Source# dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word) Source# gmapT :: (forall b. Data b => b -> b) -> Word -> WordSource# gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r Source# gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r Source# gmapQ :: (forall d. Data d => d -> u) -> Word -> [u] Source# gmapQi :: Int -> (forall d. Data d => d -> u) -> Word -> u Source# gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word -> m WordSource# gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m WordSource# gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m WordSource# | |
NumWordSource# | Since: 2.1 |
OrdWord | |
ReadWordSource# | Since: 4.5.0.0 |
RealWordSource# | Since: 2.1 |
ShowWordSource# | Since: 2.1 |
IxWordSource# | Since: 4.6.0.0 |
FiniteBitsWordSource# | Since: 4.6.0.0 |
BitsWordSource# | Since: 2.1 |
Defined in Data.Bits Methods (.&.) :: Word -> Word -> WordSource# (.|.) :: Word -> Word -> WordSource# xor :: Word -> Word -> WordSource# complement :: Word -> WordSource# shift :: Word -> Int -> WordSource# rotate :: Word -> Int -> WordSource# setBit :: Word -> Int -> WordSource# clearBit :: Word -> Int -> WordSource# complementBit :: Word -> Int -> WordSource# testBit :: Word -> Int -> BoolSource# bitSizeMaybe :: Word -> MaybeIntSource# isSigned :: Word -> BoolSource# shiftL :: Word -> Int -> WordSource# unsafeShiftL :: Word -> Int -> WordSource# shiftR :: Word -> Int -> WordSource# unsafeShiftR :: Word -> Int -> WordSource# rotateL :: Word -> Int -> WordSource# | |
StorableWordSource# | Since: 2.1 |
PrintfArgWordSource# | Since: 2.1 |
Defined in Text.Printf | |
Generic1 (URecWord :: k -> Type)Source# | Since: 4.9.0.0 |
Foldable (UWord :: Type -> Type)Source# | Since: 4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UWord m -> m Source# foldMap :: Monoid m => (a -> m) -> UWord a -> m Source# foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source# foldr :: (a -> b -> b) -> b -> UWord a -> b Source# foldr' :: (a -> b -> b) -> b -> UWord a -> b Source# foldl :: (b -> a -> b) -> b -> UWord a -> b Source# foldl' :: (b -> a -> b) -> b -> UWord a -> b Source# foldr1 :: (a -> a -> a) -> UWord a -> a Source# foldl1 :: (a -> a -> a) -> UWord a -> a Source# toList :: UWord a -> [a] Source# null :: UWord a -> BoolSource# length :: UWord a -> IntSource# elem :: Eq a => a -> UWord a -> BoolSource# maximum :: Ord a => UWord a -> a Source# minimum :: Ord a => UWord a -> a Source# | |
Traversable (UWord :: Type -> Type)Source# | Since: 4.9.0.0 |
Functor (URecWord :: Type -> Type)Source# | Since: 4.9.0.0 |
Eq (URecWord p)Source# | Since: 4.9.0.0 |
Ord (URecWord p)Source# | Since: 4.9.0.0 |
Show (URecWord p)Source# | Since: 4.9.0.0 |
Generic (URecWord p)Source# | Since: 4.9.0.0 |
dataURecWord (p :: k)Source# | Used for marking occurrences of Since: 4.9.0.0 |
typeRep1 (URecWord :: k -> Type)Source# | |
Defined in GHC.Generics | |
typeRep (URecWord p)Source# | |
Defined in GHC.Generics |
8-bit unsigned integer type
Instances
16-bit unsigned integer type
Instances
32-bit unsigned integer type
Instances
64-bit unsigned integer type
Instances
byte swapping
bit reversal
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.