Is there a more idiomatic way to implement the following? I feel like I\'m missing a way to get rid of the lambda, but couldn\'t figure out a way to convert it to point-free. Ma
I'd just use sequence from Control.Monad:
sequence
> fmap sum $ sequence [Just 3, Just 4] Just 7 > fmap sum $ sequence [Just 3, Just 4, Nothing] Nothing
For the point-free form:
sumMaybe :: Num a => [Maybe a] -> Maybe a sumMaybe = fmap sum . sequence