Commit c037793b authored by simonmar's avatar simonmar
Browse files

[project @ 1999-05-21 13:37:07 by simonmar]

Misc patches from SLPJ.
parent f922d703
......@@ -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
......
......@@ -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}
......
......@@ -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
......
......@@ -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 "'\\''"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment