
18 May
2009
18 May
'09
11:23 p.m.
On Mon, May 18, 2009 at 9:56 PM, aditya siram
Hi all, I would like to define a function that takes a list and a function that evaluates each member of the list to a Maybe value and output the first element in the list that evaluates to 'Just y', or 'Nothing' once the list has been completely processed. So something like:
findMaybe :: [a] -> (a -> Maybe b) -> Maybe b
There are a couple of ways, the first one I could think of was:
findMaybe xs f = mconcat $ map f xs
where mconcat is found in Data.Monoid Antoine