module Main where
import Data.Char
import Text.Printf
isVowel :: Char -> Bool
isVowel c = toUpper c `elem` "AEIOU"
main :: IO ()
main = do
content <- getContents
let (vowels, consonants) = counts isVowel $ filter isAlpha content
let total = fromIntegral (vowels + consonants) -- $ length vowels + length consonants
printf "Vowels : %.2f\n" (fromIntegral vowels / total :: Double) -- use Double instead
printf "Consonants: %.2f\n" (fromIntegral consonants / total :: Double)
counts :: (a -> Bool) -> [a] -> (Int,Int)
counts p [] = (0,0)
counts p xs = go 0 0 p xs
where go :: Int -> Int -> (a -> Bool) -> [a] -> (Int,Int)
go m n p [] = (m,n)
go m n p (x:xs)
| p x = let m' = m+1 in m' `seq` go m' n p xs
| otherwise = let n' = n+1 in n' `seq` go m n' p xs