X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelEnum.lhs;h=882d69a0371f6aa56e7328c06159f583452ec1ff;hb=b8b6d871386ce70c5bf54f3bd91efa2dc7364eb7;hp=92f97454479c19f421ded1ff7f5247c28450922d;hpb=f2eda36747e019fbf2e546f80a24c5e231e12460;p=ghc-hetmet.git diff --git a/ghc/lib/std/PrelEnum.lhs b/ghc/lib/std/PrelEnum.lhs index 92f9745..882d69a 100644 --- a/ghc/lib/std/PrelEnum.lhs +++ b/ghc/lib/std/PrelEnum.lhs @@ -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