14 Aug
2011
14 Aug
'11
2:41 a.m.
On Sat, Aug 13, 2011 at 9:23 PM, Ertugrul Soeylemez <es@ertes.de> wrote:
Mihai Maruseac <mihai.maruseac@gmail.com> 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 :)