Just
import Data.Maybe (listToMaybe) getA xs = listToMaybe [e | e@(A _) <- xs]
Application: even better, with the future, using an empty recording template (kudos hammar):
getA xs = listToMaybe [e | e@(A{}) <- xs]
Note, however, that this works so neatly for matching constructors. For general properties, find better:
get prop xs = listToMaybe [e | e <- xs, prop e] get prop xs = listToMaybe (filter prop xs) get prop xs = find prop xs
Daniel Fischer
source share