1 {-# LANGUAGE CPP, PackageImports #-}

3 {-# LANGUAGE Safe #-}

4 #endif

7 -- * Unsigned integral types

9 -- $notes

11 Word,

17 -- SDM: removed after 'Prelude.fromIntegral':

18 -- ..., which is specialized for all the common cases

19 -- so should be fast enough

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.

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.

31 {- $notes

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.

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.

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.

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.

53 -}