[project @ 1999-05-21 13:37:07 by simonmar]
authorsimonmar <unknown>
Fri, 21 May 1999 13:37:08 +0000 (13:37 +0000)
committersimonmar <unknown>
Fri, 21 May 1999 13:37:08 +0000 (13:37 +0000)
Misc patches from SLPJ.

ghc/lib/std/PrelBase.lhs
ghc/lib/std/PrelEnum.lhs
ghc/lib/std/PrelList.lhs
ghc/lib/std/PrelShow.lhs

index 314be3b..9cd1c88 100644 (file)
@@ -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
index 4651f0c..040828a 100644 (file)
@@ -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}
index d6514e3..2e4a076 100644 (file)
@@ -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
index eebdcc6..59b768b 100644 (file)
@@ -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 "'\\''"