[project @ 2001-09-07 16:52:53 by simonpj]
[ghc-hetmet.git] / ghc / lib / std / PrelEnum.lhs
index 0104e46..48abe32 100644 (file)
@@ -1,12 +1,10 @@
 % -----------------------------------------------------------------------------
-% $Id: PrelEnum.lhs,v 1.13 2001/02/18 14:45:15 qrczak Exp $
+% $Id: PrelEnum.lhs,v 1.16 2001/08/29 09:34:05 simonmar Exp $
 %
-% (c) The University of Glasgow, 1992-2000
+% (c) The University of Glasgow, 1992-2001
 %
 
-\section[PrelBounded]{Module @PrelBounded@}
-
-Instances of Bounded for various datatypes.
+Instances of Bounded and Enum for various datatypes.
 
 \begin{code}
 {-# OPTIONS -fno-implicit-prelude #-}
@@ -314,7 +312,8 @@ instance  Enum Int  where
     fromEnum x = x
 
     {-# INLINE enumFrom #-}
-    enumFrom (I# x) = eftInt x 2147483647#
+    enumFrom (I# x) = eftInt x maxInt#
+        where I# maxInt# = maxInt
        -- Blarg: technically I guess enumFrom isn't strict!
 
     {-# INLINE enumFromTo #-}
@@ -374,14 +373,14 @@ efdtIntList x1 x2 y
     lim   = y -# delta
 
 efdIntFB c n x1 x2
-  | delta >=# 0# = go_up_int_fb c n x1 delta (  2147483647#  -# delta)
-  | otherwise    = go_dn_int_fb c n x1 delta ((-2147483648#) -# delta)
+  | delta >=# 0# = case maxInt of I# y -> go_up_int_fb c n x1 delta (y -# delta)
+  | otherwise    = case minInt of I# y -> go_dn_int_fb c n x1 delta (y -# delta)
   where
     delta = x2 -# x1
 
 efdIntList x1 x2
-  | delta >=# 0# = go_up_int_list x1 delta (  2147483647#  -# delta)
-  | otherwise    = go_dn_int_list x1 delta ((-2147483648#) -# delta)
+  | delta >=# 0# = case maxInt of I# y -> go_up_int_list x1 delta (y -# delta)
+  | otherwise    = case minInt of I# y -> go_dn_int_list x1 delta (y -# delta)
   where
     delta = x2 -# x1