[project @ 1999-01-24 14:43:19 by sof]
authorsof <unknown>
Sun, 24 Jan 1999 14:43:19 +0000 (14:43 +0000)
committersof <unknown>
Sun, 24 Jan 1999 14:43:19 +0000 (14:43 +0000)
- Completed lists of coercion functions provided.
- Clarified what behaviour to expect from Enum instances.

ghc/docs/libraries/Int.sgml
ghc/docs/libraries/Word.sgml

index a36c667..0e29d6c 100644 (file)
@@ -33,21 +33,56 @@ instance Enum     I
 instance Ix       I
 instance Bits     I
 </verb></tscreen>
-Plus
+
+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
-intToInt8  :: Int   -> Int8
 int16ToInt :: Int16 -> Int
-intToInt16 :: Int   -> Int16
 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>
-Hugs does not provide <tt/Int64/ at the moment.
+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>
-ToDo: complete the set of coercion functions.
+Hugs does not provide <tt/Int64/ at the moment.
 
 </itemize>
index eb82c2a..79af677 100644 (file)
@@ -6,15 +6,18 @@ This library provides unsigned integers of various sizes.
 The types supported are as follows:
 
 <tabular ca="ll">
-type    | number of bits @
-<!-- <hline>  -->
+<!-- ToDo: figure out why the ldoc DTD doesn't allow hline's - it looks as if -->
+<!-- it should. -->
+<!-- <hline> -->
+type     | number of bits @
 Word8    | 8  @
 Word16   | 16 @
 Word32   | 32 @
 Word64   | 64 @
-<!-- <hline>  -->
+<!-- <hline> -->
 </tabular>
 
+
 For each type <it/W/ above, we provide the following functions and
 instances.  The type <it/I/ refers to the signed integer type of the
 same size.
@@ -35,17 +38,35 @@ instance Bits     W
 </verb></tscreen>
 Plus
 <tscreen><verb>
-word8ToWord32  :: Word8  -> Word32
+word8ToWord16  :: Word8   -> Word16
+word8ToWord32  :: Word8   -> Word32
+word8ToWord64  :: Word8   -> Word64
+
+word16ToWord8   :: Word16  -> Word8
+word16ToWord32  :: Word16  -> Word32
+word16ToWord64  :: Word16  -> Word64
+
 word32ToWord8  :: Word32 -> Word8
-word16ToWord32 :: Word16 -> Word32
 word32ToWord16 :: Word32 -> Word16
+word32ToWord64 :: Word32 -> Word64
+
+word64ToWord8  :: Word64 -> Word8
+word64ToWord16 :: Word64 -> Word16
+word64ToWord32 :: Word64 -> Word32
 
 word8ToInt     :: Word8  -> Int
-intToWord8     :: Int    -> Word8
 word16ToInt    :: Word16 -> Int
-intToWord16    :: Int    -> Word16
 word32ToInt    :: Word32 -> Int
+word64ToInt    :: Word64 -> Int
+
+intToWord8     :: Int    -> Word8
+intToWord16    :: Int    -> Word16
 intToWord32    :: Int    -> Word32
+intToWord64    :: Int    -> Word64
+
+word64ToInteger :: Word64  -> Integer
+integerToWord64 :: Integer -> Word64
+
 </verb></tscreen>
 
 Notes: 
@@ -64,9 +85,6 @@ Likewise, <tt/iToW/ converts signed n-bit values to the
 corresponding unsigned n-bit value.
 
 <item>
-ToDo: complete the set of coercion functions.
-
-<item>
 Use <tt/Prelude.fromIntegral :: (Integral a, Num b) => a -> b/ to
 coerce between different sizes or to preserve sign when converting
 between values of the same size.
@@ -79,17 +97,16 @@ no demand for it.  Doing so would require <tt/Bits.bitSize/ to return
 <tt/Maybe Int/.
 
 <item>
-The <tt/Enum/ instances stop when they reach their upper or lower
-bound --- they don't overflow the way the <tt/Int/ and <tt/Float/
-instances do.
-
-<item>
-It would be useful to provide a function (or a family of functions?)
-which coerced between any two Word types (without going through
-Integer).
+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/Word/ types defined here.
 
 </itemize>
 
-Hugs only provides <tt/Eq/, <tt/Ord/, <tt/Read/ and <tt/Show/
-instances for <tt/Word64/ at the moment.
+<bf/Implementation notes:/
 
+<itemize>
+<item> Hugs only provides <tt/Eq/, <tt/Ord/, <tt/Read/ and <tt/Show/
+instances for <tt/Word64/ at the moment.
+</itemize>