Hello,
I'm looking for a good example of function composition. It's very impressive, how concise you can extract information out of a file in Haskell. So I write a short programm, which gets all title words out of a given file sorted by their length.
How could the following programm be improved?


import Data.Char (isUpper,isLower)
import Data.List (sortBy)
import Data.Ord (comparing)

isTitle word=  
  isFirstUpperCase ( word) && isTailLowerCase ( word )
  where isFirstUpperCase= isUpper . head
    isTailLowerCase= all isLower . tail

main = do
  putStrLn "The name of the input file:"
  file <- getLine
  inputString <- readFile file
  let allTitles= reverse . sortBy (comparing length ) . filter isTitle $ words inputString
  putStrLn $ show $ take 15  allTitles
  putStrLn $ show (length allTitles) ++ " titles in " ++ file


Thanks in advance,
Rainer
-- 
Rainer Grimm  rainer@grimm-jaud.de
              http://www.grimm-jaud.de