[project @ 2001-08-04 06:19:54 by ken]
[ghc-hetmet.git] / ghc / lib / std / PrelInt.lhs
index ed48a37..bd292b0 100644 (file)
@@ -4,7 +4,7 @@
 \section[PrelInt]{Module @PrelInt@}
 
 \begin{code}
-{-# OPTIONS -monly-3-regs #-}
+{-# OPTIONS -fno-implicit-prelude #-}
 
 #include "MachDeps.h"
 
@@ -20,6 +20,7 @@ import PrelRead
 import PrelArr
 import PrelBits
 import PrelWord
+import PrelShow
 
 ------------------------------------------------------------------------
 -- type Int8
@@ -122,9 +123,10 @@ instance Bits Int8 where
     isSigned _                = True
 
 {-# RULES
-"fromIntegral/a->Int8" fromIntegral = \x -> case fromIntegral x of I# x# -> I8# (intToInt8# x#)
-"fromIntegral/Int8->a" fromIntegral = \(I8# x#) -> fromIntegral (I# x#)
-    #-}
+"fromIntegral/Int8->Int8" fromIntegral = id :: Int8 -> Int8
+"fromIntegral/a->Int8"    fromIntegral = \x -> case fromIntegral x of I# x# -> I8# (intToInt8# x#)
+"fromIntegral/Int8->a"    fromIntegral = \(I8# x#) -> fromIntegral (I# x#)
+  #-}
 
 ------------------------------------------------------------------------
 -- type Int16
@@ -227,9 +229,12 @@ instance Bits Int16 where
     isSigned _                 = True
 
 {-# RULES
-"fromIntegral/a->Int16" fromIntegral = \x -> case fromIntegral x of I# x# -> I16# (intToInt16# x#)
-"fromIntegral/Int16->a" fromIntegral = \(I16# x#) -> fromIntegral (I# x#)
-    #-}
+"fromIntegral/Word8->Int16"  fromIntegral = \(W8# x#) -> I16# (word2Int# x#)
+"fromIntegral/Int8->Int16"   fromIntegral = \(I8# x#) -> I16# x#
+"fromIntegral/Int16->Int16"  fromIntegral = id :: Int16 -> Int16
+"fromIntegral/a->Int16"      fromIntegral = \x -> case fromIntegral x of I# x# -> I16# (intToInt16# x#)
+"fromIntegral/Int16->a"      fromIntegral = \(I16# x#) -> fromIntegral (I# x#)
+  #-}
 
 ------------------------------------------------------------------------
 -- type Int32
@@ -243,10 +248,6 @@ instance Bits Int16 where
 
 data Int32 = I32# Int# deriving (Eq, Ord)
 
-#if WORD_SIZE_IN_BYTES == 4
-{-# RULES "intToInt32#" forall x#. intToInt32# x# = x# #-}
-#endif
-
 instance CCallable Int32
 instance CReturnable Int32
 
@@ -343,9 +344,14 @@ instance Bits Int32 where
     isSigned _                 = True
 
 {-# RULES
-"fromIntegral/a->Int32" fromIntegral = \x -> case fromIntegral x of I# x# -> I32# (intToInt32# x#)
-"fromIntegral/Int32->a" fromIntegral = \(I32# x#) -> fromIntegral (I# x#)
-    #-}
+"fromIntegral/Word8->Int32"  fromIntegral = \(W8# x#) -> I32# (word2Int# x#)
+"fromIntegral/Word16->Int32" fromIntegral = \(W16# x#) -> I32# (word2Int# x#)
+"fromIntegral/Int8->Int32"   fromIntegral = \(I8# x#) -> I32# x#
+"fromIntegral/Int16->Int32"  fromIntegral = \(I16# x#) -> I32# x#
+"fromIntegral/Int32->Int32"  fromIntegral = id :: Int32 -> Int32
+"fromIntegral/a->Int32"      fromIntegral = \x -> case fromIntegral x of I# x# -> I32# (intToInt32# x#)
+"fromIntegral/Int32->a"      fromIntegral = \(I32# x#) -> fromIntegral (I# x#)
+  #-}
 
 ------------------------------------------------------------------------
 -- type Int64
@@ -395,6 +401,8 @@ instance Enum Int64 where
         | otherwise     = fromEnumError "Int64" x
     enumFrom            = integralEnumFrom
     enumFromThen        = integralEnumFromThen
+    enumFromTo          = integralEnumFromTo
+    enumFromThenTo      = integralEnumFromThenTo
 
 instance Integral Int64 where
     quot    x@(I64# x#) y@(I64# y#)
@@ -465,12 +473,11 @@ foreign import "stg_plusInt64"     unsafe plusInt64#     :: Int64# -> Int64# ->
 foreign import "stg_minusInt64"    unsafe minusInt64#    :: Int64# -> Int64# -> Int64#
 foreign import "stg_timesInt64"    unsafe timesInt64#    :: Int64# -> Int64# -> Int64#
 foreign import "stg_negateInt64"   unsafe negateInt64#   :: Int64# -> Int64#
-foreign import "stg_quotWord64"    unsafe quotInt64#     :: Int64# -> Int64# -> Int64#
-foreign import "stg_remWord64"     unsafe remInt64#      :: Int64# -> Int64# -> Int64#
+foreign import "stg_quotInt64"     unsafe quotInt64#     :: Int64# -> Int64# -> Int64#
+foreign import "stg_remInt64"      unsafe remInt64#      :: Int64# -> Int64# -> Int64#
 foreign import "stg_intToInt64"    unsafe intToInt64#    :: Int# -> Int64#
 foreign import "stg_int64ToInt"    unsafe int64ToInt#    :: Int64# -> Int#
 foreign import "stg_wordToWord64"  unsafe wordToWord64#  :: Word# -> Word64#
-foreign import "stg_word64ToWord"  unsafe word64ToWord#  :: Word64# -> Word#
 foreign import "stg_int64ToWord64" unsafe int64ToWord64# :: Int64# -> Word64#
 foreign import "stg_word64ToInt64" unsafe word64ToInt64# :: Word64# -> Int64#
 foreign import "stg_and64"         unsafe and64#         :: Word64# -> Word64# -> Word64#
@@ -490,7 +497,7 @@ foreign import "stg_shiftRL64"     unsafe shiftRL64#     :: Word64# -> Int# -> W
 "fromIntegral/Int64->Word"   fromIntegral = \(I64# x#) -> W#   (int2Word# (int64ToInt# x#))
 "fromIntegral/Int64->Word64" fromIntegral = \(I64# x#) -> W64# (int64ToWord64# x#)
 "fromIntegral/Int64->Int64"  fromIntegral = id :: Int64 -> Int64
-    #-}
+  #-}
 
 #else
 
@@ -566,9 +573,9 @@ instance Bits Int64 where
     isSigned _                 = True
 
 {-# RULES
-"fromIntegral/a->Int64" fromIntegral = \x -> case fromIntegral x of I# x# -> I64# (intToInt64# x#)
+"fromIntegral/a->Int64" fromIntegral = \x -> case fromIntegral x of I# x# -> I64# x#
 "fromIntegral/Int64->a" fromIntegral = \(I64# x#) -> fromIntegral (I# x#)
-    #-}
+  #-}
 
 #endif