
13 Aug
2011
13 Aug
'11
2:41 p.m.
On Sat, Aug 13, 2011 at 9:23 PM, Ertugrul Soeylemez
Mihai Maruseac
wrote: I'd go by:
fn l = let l' = filter (/= Nothing) l in if l' == [] then Nothing else head l'
If you want to disregard the useful Monoid instance of Maybe, then here is a nicer way to express this:
fn :: [Maybe a] -> Maybe a fn = listToMaybe . catMaybes
I stand corrected. I only wanted a simple solution but the Monoid instance is more expressive :)