% -----------------------------------------------------------------------------
-% $Id: PrelEnum.lhs,v 1.11 2000/06/30 13:39:35 simonmar Exp $
+% $Id: PrelEnum.lhs,v 1.14 2001/07/24 06:31:35 ken Exp $
%
% (c) The University of Glasgow, 1992-2000
%
\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#))
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 #-}
-- 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
fromEnum x = x
{-# INLINE enumFrom #-}
- enumFrom (I# x) = eftInt x 2147483647#
+ enumFrom (I# x) = case maxInt of I# y -> eftInt x y
-- Blarg: technically I guess enumFrom isn't strict!
{-# INLINE enumFromTo #-}
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