[project @ 2000-08-29 16:35:56 by simonpj]
authorsimonpj <unknown>
Tue, 29 Aug 2000 16:35:56 +0000 (16:35 +0000)
committersimonpj <unknown>
Tue, 29 Aug 2000 16:35:56 +0000 (16:35 +0000)
Add filterFB comment

ghc/lib/std/PrelList.lhs

index 2f7ad22..496aa1e 100644 (file)
@@ -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)