Add explicit `{-# LANGUAGE CPP, PackageImports #-}` pragmas
[packages/haskell2010.git] / Data / Word.hs
1 {-# LANGUAGE CPP, PackageImports #-}
2 #if __GLASGOW_HASKELL__ >= 701
3 {-# LANGUAGE Safe #-}
4 #endif
5
6 module Data.Word (
7 -- * Unsigned integral types
8
9 -- $notes
10
11 Word,
12 Word8, Word16, Word32, Word64,
13
14 ) where
15 import "base" Data.Word
16
17 -- SDM: removed after 'Prelude.fromIntegral':
18 -- ..., which is specialized for all the common cases
19 -- so should be fast enough
20
21 -- SDM: removed: It would be very natural to add a type @Natural@ providing an
22 -- unbounded size unsigned integer, just as 'Prelude.Integer' provides
23 -- unbounded size signed integers. We do not do that yet since there is
24 -- no demand for it.
25
26 -- SDM: removed, after "All arithmetic is performed module 2^n...". Neither
27 -- Ian Lynagh nor I understand what this means:
28 -- One non-obvious consequence of this is that 'Prelude.negate'
29 -- should /not/ raise an error on negative arguments.
30
31 {- $notes
32
33 This module provides unsigned integer types of unspecified width ('Word')
34 and fixed widths ('Word8', 'Word16', 'Word32' and 'Word64'). All
35 arithmetic is performed modulo 2^n, where @n@ is the number of bits in
36 the type.
37
38 For coercing between any two integer types, use
39 'Prelude.fromIntegral'. Coercing word types to and from integer
40 types preserves representation, not sign.
41
42 The rules that hold for 'Prelude.Enum' instances over a bounded type
43 such as 'Prelude.Int' (see the section of the Haskell language report dealing
44 with arithmetic sequences) also hold for the 'Prelude.Enum' instances
45 over the various 'Word' types defined here.
46
47 Right and left shifts by amounts greater than or equal to the width of
48 the type result in a zero result. This is contrary to the behaviour
49 in C, which is undefined; a common interpretation is to truncate the
50 shift count to the width of the type, for example @1 \<\< 32 == 1@ in
51 some C implementations.
52
53 -}
54