summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
85c61e7)
Uncomment {-# SPECIALISE instance Eq [Char] #-}
{-# SPECIALISE instance Ord [Char] #-}
Remove explicit (<), (<=), (>), (>=) in instance Ord [a].
eqString is defined as (==) instead of vice versa.
ghc generates good specialized code for these automatically.
% -----------------------------------------------------------------------------
% -----------------------------------------------------------------------------
-% $Id: PrelBase.lhs,v 1.42 2001/02/28 00:01:03 qrczak Exp $
+% $Id: PrelBase.lhs,v 1.43 2001/03/01 09:23:40 qrczak Exp $
%
% (c) The University of Glasgow, 1992-2000
%
%
% (c) The University of Glasgow, 1992-2000
%
instance (Eq a) => Eq [a] where
instance (Eq a) => Eq [a] where
{-# SPECIALISE instance Eq [Char] #-}
{-# SPECIALISE instance Eq [Char] #-}
[] == [] = True
(x:xs) == (y:ys) = x == y && xs == ys
_xs == _ys = False
instance (Ord a) => Ord [a] where
[] == [] = True
(x:xs) == (y:ys) = x == y && xs == ys
_xs == _ys = False
instance (Ord a) => Ord [a] where
{-# SPECIALISE instance Ord [Char] #-}
{-# SPECIALISE instance Ord [Char] #-}
--}
- a < b = case compare a b of { LT -> True; EQ -> False; GT -> False }
- a <= b = case compare a b of { LT -> True; EQ -> True; GT -> False }
- a >= b = case compare a b of { LT -> False; EQ -> True; GT -> True }
- a > b = case compare a b of { LT -> False; EQ -> False; GT -> True }
compare (x:xs) (y:ys) = case compare x y of
compare (x:xs) (y:ys) = case compare x y of
- LT -> LT
- GT -> GT
- EQ -> compare xs ys
+ EQ -> compare xs ys
+ other -> other
instance Functor [] where
fmap = map
instance Functor [] where
fmap = map
%*********************************************************
\begin{code}
%*********************************************************
\begin{code}
(C# c1) < (C# c2) = c1 `ltChar#` c2
chr :: Int -> Char
(C# c1) < (C# c2) = c1 `ltChar#` c2
chr :: Int -> Char
-chr (I# i) | i >=# 0# && i <=# 0x10FFFF#
- = C# (chr# i)
- | otherwise = error "Prelude.chr: bad argument"
+chr (I# i) | i >=# 0# && i <=# 0x10FFFF# = C# (chr# i)
+ | otherwise = error "Prelude.chr: bad argument"
unsafeChr :: Int -> Char
unsafeChr (I# i) = C# (chr# i)
unsafeChr :: Int -> Char
unsafeChr (I# i) = C# (chr# i)
\end{code}
String equality is used when desugaring pattern-matches against strings.
\end{code}
String equality is used when desugaring pattern-matches against strings.
-It's worth making it fast, and providing a rule to use the fast version
-where possible.
\begin{code}
eqString :: String -> String -> Bool
\begin{code}
eqString :: String -> String -> Bool
-eqString [] [] = True
-eqString (C# c1 : cs1) (C# c2 : cs2) = c1 `eqChar#` c2 && cs1 `eqString` cs2
-eqString _ _ = False
-
-{-# RULES
-"eqString" (==) = eqString
- #-}
\end{code}
%*********************************************************
\end{code}
%*********************************************************