summaryrefslogtreecommitdiff
path: root/ghc/docs/libraries/Int.sgml
blob: 0e29d6cf615e15eaa7dd163f1f9744efab3f3df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<sect> <idx/Int/
<label id="sec:Int">
<p>

This library provides signed integers of various sizes.  The types
supported are as follows:

<tabular ca="ll">
type    | number of bits @ 
<!-- <hline>  -->
Int8    | 8  @
Int16   | 16 @
Int32   | 32 @
Int64   | 64 @
<!-- <hline>  -->
</tabular>

For each type <it/I/ above, we provide the following instances.

<tscreen><verb>
data I            -- Signed Ints
iToInt            :: I -> Int  -- not provided for Int64
intToI            :: Int -> I  -- not provided for Int64
instance Eq       I
instance Ord      I
instance Show     I
instance Read     I
instance Bounded  I
instance Num      I
instance Real     I
instance Integral I
instance Enum     I
instance Ix       I
instance Bits     I
</verb></tscreen>

Plus the coercion functions

<tscreen><verb>
int8ToInt16 :: Int8   -> Int16
int8ToInt32 :: Int8   -> Int32
int8ToInt64 :: Int8   -> Int64

int16ToInt8  :: Int16 -> Int8
int16ToInt32 :: Int16 -> Int32
int16ToInt64 :: Int16 -> Int64

int32ToInt8  :: Int32 -> Int8
int32ToInt16 :: Int32 -> Int16
int32ToInt64 :: Int32 -> Int64

int64ToInt8  :: Int64 -> Int8
int64ToInt16 :: Int64 -> Int16
int64ToInt32 :: Int64 -> Int32

int8ToInt  :: Int8  -> Int
int16ToInt :: Int16 -> Int
int32ToInt :: Int32 -> Int
int64ToInt :: Int64 -> Int

intToInt8  :: Int   -> Int8
intToInt16 :: Int   -> Int16
intToInt32 :: Int   -> Int32
intToInt64 :: Int   -> Int64

integerToInt8  :: Integer -> Int8
integerToInt16 :: Integer -> Int16
integerToInt32 :: Integer -> Int32
integerToInt64 :: Integer -> Int64

int64ToInteger :: Int64 -> Integer
int32ToInteger :: Int32 -> Integer
int16ToInteger :: Int16 -> Integer
int8ToInteger  :: Int8  -> Integer

</verb></tscreen>

<itemize>
<item>
The rules that hold for <tt/Enum/ instances over a bounded type
such as <tt/Int/ (see the section of the Haskell report dealing
with arithmetic sequences) also hold for the <tt/Enum/ instances
over the various <tt/Int/ types defined here.

<item>
Hugs does not provide <tt/Int64/ at the moment.

</itemize>