% -----------------------------------------------------------------------------
-% $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 #-}
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 #-}
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