X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelEnum.lhs;h=48abe323ce4293d9430957ffab9ebcc3e81283c3;hb=a49a772808296f7d39c079e0e430e80fe94a89c0;hp=0104e46f9b1887fbfd98785b23e288398280b7f9;hpb=77448dfad0a5b02e98f036214409b55a54f7eadc;p=ghc-hetmet.git diff --git a/ghc/lib/std/PrelEnum.lhs b/ghc/lib/std/PrelEnum.lhs index 0104e46..48abe32 100644 --- a/ghc/lib/std/PrelEnum.lhs +++ b/ghc/lib/std/PrelEnum.lhs @@ -1,12 +1,10 @@ % ----------------------------------------------------------------------------- -% $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 #-} @@ -314,7 +312,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 +373,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