From c037793b61f2cd90b28d7b144b9823ca4ddd96c5 Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 21 May 1999 13:37:08 +0000 Subject: [PATCH] [project @ 1999-05-21 13:37:07 by simonmar] Misc patches from SLPJ. --- ghc/lib/std/PrelBase.lhs | 6 +++--- ghc/lib/std/PrelEnum.lhs | 23 ++++++++++++++++++++++- ghc/lib/std/PrelList.lhs | 4 ++-- ghc/lib/std/PrelShow.lhs | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ghc/lib/std/PrelBase.lhs b/ghc/lib/std/PrelBase.lhs index 314be3b..9cd1c88 100644 --- a/ghc/lib/std/PrelBase.lhs +++ b/ghc/lib/std/PrelBase.lhs @@ -50,7 +50,7 @@ class (Eq a) => Ord a where -- Using compare can be more efficient for complex types. compare x y | x == y = EQ - | x <= y = LT + | x < y = LT | otherwise = GT x <= y = case compare x y of { GT -> False; other -> True } @@ -309,8 +309,8 @@ zeroInt, oneInt, twoInt, maxInt, minInt :: Int zeroInt = I# 0# oneInt = I# 1# twoInt = I# 2# -maxInt = I# (-2147483648#) -- GHC <= 2.09 had this at -2147483647 -minInt = I# 2147483647# +minInt = I# (-2147483648#) -- GHC <= 2.09 had this at -2147483647 +maxInt = I# 2147483647# instance Eq Int where (==) x y = x `eqInt` y diff --git a/ghc/lib/std/PrelEnum.lhs b/ghc/lib/std/PrelEnum.lhs index 4651f0c..040828a 100644 --- a/ghc/lib/std/PrelEnum.lhs +++ b/ghc/lib/std/PrelEnum.lhs @@ -265,7 +265,7 @@ instance Enum Int where enumFromTo (I# x) (I# y) = build (\ c n -> eftIntFB c n x y) {-# INLINE enumFromThen #-} - enumFromThen (I# x1) (I# x2) = build (\ c n -> efdtIntFB c n x1 x2 2147483647#) + enumFromThen (I# x1) (I# x2) = build (\ c n -> efdIntFB c n x1 x2) {-# INLINE enumFromThenTo #-} enumFromThenTo (I# x1) (I# x2) (I# y) = build (\ c n -> efdtIntFB c n x1 x2 y) @@ -308,9 +308,30 @@ efdtIntList x1 x2 y go_dn x | y -# x ># delta = [I# x] | otherwise = I# x : go_dn (x +# delta) +efdIntFB c n x1 x2 + | delta >=# 0# = go_up x1 + | otherwise = go_dn x1 + where + delta = x2 -# x1 + go_up x | 2147483647# -# x <# delta = I# x `c` n + | otherwise = I# x `c` go_up (x +# delta) + go_dn x | (-2147483648#) -# x ># delta = I# x `c` n + | otherwise = I# x `c` go_dn (x +# delta) + +efdIntList x1 x2 + | delta >=# 0# = go_up x1 + | otherwise = go_dn x1 + where + delta = x2 -# x1 + go_up x | 2147483647# -# x <# delta = [I# x] + | otherwise = I# x : go_up (x +# delta) + go_dn x | (-2147483648#) -# x ># delta = [I# x] + | otherwise = I# x : go_dn (x +# delta) + {-# RULES "eftIntList" eftIntFB (:) [] = eftIntList +"efdIntList" efdIntFB (:) [] = efdIntList "efdtIntList" efdtIntFB (:) [] = efdtIntList #-} \end{code} diff --git a/ghc/lib/std/PrelList.lhs b/ghc/lib/std/PrelList.lhs index d6514e3..2e4a076 100644 --- a/ghc/lib/std/PrelList.lhs +++ b/ghc/lib/std/PrelList.lhs @@ -437,8 +437,8 @@ foldr2_left k z x r (y:ys) = k x y (r ys) foldr2_right k z y r [] = z foldr2_right k z y r (x:xs) = k x y (r xs) --- foldr2 k z xs ys = foldr (foldr2_left k z) z xs ys --- foldr2 k z xs ys = foldr (foldr2_right k z) z ys xs +-- foldr2 k z xs ys = foldr (foldr2_left k z) (\_ -> z) xs ys +-- foldr2 k z xs ys = foldr (foldr2_right k z) (\_ -> z) ys xs {-# RULES "foldr2/left" forall k,z,ys,g::forall b.(a->b->b)->b->b . foldr2 k z (build g) ys = g (foldr2_left k z) (\_ -> z) ys diff --git a/ghc/lib/std/PrelShow.lhs b/ghc/lib/std/PrelShow.lhs index eebdcc6..59b768b 100644 --- a/ghc/lib/std/PrelShow.lhs +++ b/ghc/lib/std/PrelShow.lhs @@ -84,7 +84,7 @@ instance Show Bool where instance Show Ordering where showsPrec _ LT = showString "LT" showsPrec _ EQ = showString "EQ" - showsPrec _ GT = showString "EQ" + showsPrec _ GT = showString "GT" instance Show Char where showsPrec _ '\'' = showString "'\\''" -- 1.7.10.4