
18 Nov
2009
18 Nov
'09
12:01 a.m.
On Tue, Nov 17, 2009 at 10:01 PM, Luke Palmer
filter even [0..] --> [0,2,4,6,8,...] searchList even [0...] --> Just [0,2,4,6,8,...]
searchList gives Nothing in exactly those cases that filter gives []. They give _|_ in exactly the same situations. searchList could well be defined as:
searchList p xs = if null ys then Nothing else Just ys where ys = filter p xs
null is strict, so searchList is just as strict as filter.
You're right. I was thinking of traverse with an exception monad.
To make up for it, I'll note that with the recently (re)proposed
mfilter, you can define searchList as:
searchList p = mfilter (not . null) . Just . filter p
--
Dave Menendez