Say I have a list like:
[Nothing, Just 1, Nothing, Just 2]
I want to get the first Just (non-error) value; in this case, it's Just 1. The only thing I can think of is:
firstJust xs = case filter isJust xs of
[] -> Nothing
Just x -> Just x
Is there a better/monad-generic way to do this?