Over on Stack Overflow, someone asked a simple Haskell question: how to test whether there is exactly one distinct vowel in a given string. To clarify, there can be any number of non-vowel characters, and the vowel may be repeated any number of times (at least once!), but no other vowels may occur.
I proposed the below solution, and am feeling fairly proud of it: it seems clean, short, general, and readable. I have a hard time imagining an improvement to it, but I know there is still plenty of room for me to get better at Haskell, so there is probably something cool I'm missing. Would someone please look over this, and tell me what could be better, or confirm that it truly has reached Nirvana?
exactlyOne :: Eq a => (a -> Bool) -> [a] -> Bool exactlyOne pred  = False exactlyOne pred (x:xs) | pred x = not . any pred . filter (/= x) $ xs | otherwise = exactlyOne pred xs exactlyOneVowel :: String -> Bool exactlyOneVowel = exactlyOne (`elem` "aeiouAEIOU")