[project @ 2001-08-21 14:44:22 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / PrelEnum.lhs
index 62f3167..882d69a 100644 (file)
@@ -1,5 +1,5 @@
 % -----------------------------------------------------------------------------
-% $Id: PrelEnum.lhs,v 1.12 2000/08/07 23:37:23 qrczak Exp $
+% $Id: PrelEnum.lhs,v 1.15 2001/08/17 17:18:54 apt Exp $
 %
 % (c) The University of Glasgow, 1992-2000
 %
@@ -180,11 +180,11 @@ instance Enum Ordering where
 \begin{code}
 instance  Bounded Char  where
     minBound =  '\0'
-    maxBound =  '\x7FFFFFFF'
+    maxBound =  '\x10FFFF'
 
 instance  Enum Char  where
     succ (C# c#)
-       | not (ord# c# ==# 0x7FFFFFFF#) = C# (chr# (ord# c# +# 1#))
+       | not (ord# c# ==# 0x10FFFF#) = C# (chr# (ord# c# +# 1#))
        | otherwise             = error ("Prelude.Enum.Char.succ: bad argument")
     pred (C# c#)
        | not (ord# c# ==# 0#)   = C# (chr# (ord# c# -# 1#))
@@ -194,7 +194,7 @@ instance  Enum Char  where
     fromEnum = ord
 
     {-# INLINE enumFrom #-}
-    enumFrom (C# x) = eftChar (ord# x) 0x7FFFFFFF#
+    enumFrom (C# x) = eftChar (ord# x) 0x10FFFF#
        -- Blarg: technically I guess enumFrom isn't strict!
 
     {-# INLINE enumFromTo #-}
@@ -235,13 +235,13 @@ eftCharList x y | x ># y    = []
 
 -- For enumFromThenTo we give up on inlining
 efdCharFB c n x1 x2
-  | delta >=# 0# = go_up_char_fb c n x1 delta 0x7FFFFFFF#
+  | delta >=# 0# = go_up_char_fb c n x1 delta 0x10FFFF#
   | otherwise    = go_dn_char_fb c n x1 delta 0#
   where
     delta = x2 -# x1
 
 efdCharList x1 x2
-  | delta >=# 0# = go_up_char_list x1 delta 0x7FFFFFFF#
+  | delta >=# 0# = go_up_char_list x1 delta 0x10FFFF#
   | otherwise    = go_dn_char_list x1 delta 0#
   where
     delta = x2 -# x1
@@ -314,7 +314,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 +375,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