[project @ 2001-08-21 14:44:22 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / PrelEnum.lhs
index 92f9745..882d69a 100644 (file)
@@ -1,6 +1,9 @@
+% -----------------------------------------------------------------------------
+% $Id: PrelEnum.lhs,v 1.15 2001/08/17 17:18:54 apt Exp $
 %
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
+% (c) The University of Glasgow, 1992-2000
 %
+
 \section[PrelBounded]{Module @PrelBounded@}
 
 Instances of Bounded for various datatypes.
@@ -177,11 +180,11 @@ instance Enum Ordering where
 \begin{code}
 instance  Bounded Char  where
     minBound =  '\0'
-    maxBound =  '\255'
+    maxBound =  '\x10FFFF'
 
 instance  Enum Char  where
     succ (C# c#)
-       | not (ord# c# ==# 255#) = 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#))
@@ -191,7 +194,7 @@ instance  Enum Char  where
     fromEnum = ord
 
     {-# INLINE enumFrom #-}
-    enumFrom (C# x) = eftChar (ord# x) 255#
+    enumFrom (C# x) = eftChar (ord# x) 0x10FFFF#
        -- Blarg: technically I guess enumFrom isn't strict!
 
     {-# INLINE enumFromTo #-}
@@ -232,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 255#
+  | 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 255#
+  | delta >=# 0# = go_up_char_list x1 delta 0x10FFFF#
   | otherwise    = go_dn_char_list x1 delta 0#
   where
     delta = x2 -# x1
@@ -311,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 #-}
@@ -371,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