Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Unsigned integral types
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.
Instances
Bounded Word | Since: base-2.1 |
Enum Word | Since: base-2.1 |
Eq Word | |
Integral Word | Since: base-2.1 |
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 |
Storable Word | Since: base-2.1 |
Defined in Foreign.Storable | |
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 # | |
FiniteBits Word | Since: base-4.6.0.0 |
Defined in Data.Bits | |
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 |
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
16-bit unsigned integer type
Instances
32-bit unsigned integer type
Instances
64-bit unsigned integer type