diff --git a/ghc/lib/std/PrelList.lhs b/ghc/lib/std/PrelList.lhs index 2f7ad22912c9dabd30a87c64e74320ea97154619..496aa1ea1215f1baabb17886e588fd3cdb4ab6ab 100644 --- a/ghc/lib/std/PrelList.lhs +++ b/ghc/lib/std/PrelList.lhs @@ -1,5 +1,5 @@ % ------------------------------------------------------------------------------ -% $Id: PrelList.lhs,v 1.20 2000/06/30 13:39:35 simonmar Exp $ +% $Id: PrelList.lhs,v 1.21 2000/08/29 16:35:56 simonpj Exp $ % % (c) The University of Glasgow, 1994-2000 % @@ -130,6 +130,15 @@ filterFB c p x r | p x = x `c` r "filterList" forall p. foldr (filterFB (:) p) [] = filterList p #-} +-- Note the filterFB rule, which has p and q the "wrong way round" in the RHS. +-- filterFB (filterFB c p) q a b +-- = if q a then filterFB c p a b else b +-- = if q a then (if p a then c a b else b) else b +-- = if q a && p a then c a b else b +-- = filterFB c (\x -> q x && p x) a b +-- I originally wrote (\x -> p x && q x), which is wrong, and actually +-- gave rise to a live bug report. SLPJ. + filterList :: (a -> Bool) -> [a] -> [a] filterList _pred [] = [] filterList pred (x:xs)