add GHC.HetMet.{hetmet_kappa,hetmet_kappa_app}
[ghc-base.git] / Data / Word.hs
1 {-# LANGUAGE CPP, NoImplicitPrelude #-}
2
3 -----------------------------------------------------------------------------
4 -- |
5 -- Module      :  Data.Word
6 -- Copyright   :  (c) The University of Glasgow 2001
7 -- License     :  BSD-style (see the file libraries/base/LICENSE)
8 -- 
9 -- Maintainer  :  libraries@haskell.org
10 -- Stability   :  experimental
11 -- Portability :  portable
12 --
13 -- Unsigned integer types.
14 --
15 -----------------------------------------------------------------------------
16
17 module Data.Word
18   (
19         -- * Unsigned integral types
20
21         Word,
22         Word8, Word16, Word32, Word64,
23
24         -- * Notes
25
26         -- $notes
27         ) where
28
29 #ifdef __GLASGOW_HASKELL__
30 import GHC.Word
31 #endif
32
33 #ifdef __HUGS__
34 import Hugs.Word
35 #endif
36
37 #ifdef __NHC__
38 import NHC.FFI (Word8, Word16, Word32, Word64)
39 import NHC.SizedTypes (Word8, Word16, Word32, Word64)   -- instances of Bits
40 type Word = Word32
41 #endif
42
43 {- $notes
44
45 * All arithmetic is performed modulo 2^n, where n is the number of
46   bits in the type.  One non-obvious consequence of this is that 'Prelude.negate'
47   should /not/ raise an error on negative arguments.
48
49 * For coercing between any two integer types, use
50   'Prelude.fromIntegral', which is specialized for all the
51   common cases so should be fast enough.  Coercing word types to and
52   from integer types preserves representation, not sign.
53
54 * It would be very natural to add a type @Natural@ providing an unbounded 
55   size unsigned integer, just as 'Prelude.Integer' provides unbounded
56   size signed integers.  We do not do that yet since there is no demand
57   for it.
58
59 * The rules that hold for 'Prelude.Enum' instances over a bounded type
60   such as 'Prelude.Int' (see the section of the Haskell report dealing
61   with arithmetic sequences) also hold for the 'Prelude.Enum' instances
62   over the various 'Word' types defined here.
63
64 * Right and left shifts by amounts greater than or equal to the width
65   of the type result in a zero result.  This is contrary to the
66   behaviour in C, which is undefined; a common interpretation is to
67   truncate the shift count to the width of the type, for example @1 \<\<
68   32 == 1@ in some C implementations. 
69 -}