From 447a6fee1adb46df5bd395222afdbf8d55af1750 Mon Sep 17 00:00:00 2001 From: sof Date: Sun, 24 Jan 1999 14:43:19 +0000 Subject: [PATCH] [project @ 1999-01-24 14:43:19 by sof] - Completed lists of coercion functions provided. - Clarified what behaviour to expect from Enum instances. --- ghc/docs/libraries/Int.sgml | 45 +++++++++++++++++++++++++++++---- ghc/docs/libraries/Word.sgml | 57 +++++++++++++++++++++++++++--------------- 2 files changed, 77 insertions(+), 25 deletions(-) diff --git a/ghc/docs/libraries/Int.sgml b/ghc/docs/libraries/Int.sgml index a36c667..0e29d6c 100644 --- a/ghc/docs/libraries/Int.sgml +++ b/ghc/docs/libraries/Int.sgml @@ -33,21 +33,56 @@ instance Enum I instance Ix I instance Bits I -Plus + +Plus the coercion functions + +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 + -Hugs does not provide -ToDo: complete the set of coercion functions. +Hugs does not provide diff --git a/ghc/docs/libraries/Word.sgml b/ghc/docs/libraries/Word.sgml index eb82c2a..79af677 100644 --- a/ghc/docs/libraries/Word.sgml +++ b/ghc/docs/libraries/Word.sgml @@ -6,15 +6,18 @@ This library provides unsigned integers of various sizes. The types supported are as follows: -type | number of bits @ - + + + +type | number of bits @ Word8 | 8 @ Word16 | 16 @ Word32 | 32 @ Word64 | 64 @ - + + For each type Plus -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 + Notes: @@ -64,9 +85,6 @@ Likewise, -ToDo: complete the set of coercion functions. - - Use 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 -The -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 -Hugs only provides + Hugs only provides -- 1.7.10.4