-- From http://learnyouahaskell.com/input-and-output, slightly changed main = chat >> putStrLn "Bye!" chat = do line <- getLine if null line then return () else do putStrLn $ reverseWords line chat reverseWords :: String -> String reverseWords = unwords . map reverse . words