import System.Environment import Control.Monad main :: IO () main = do argc <- length `fmap` getArgs when (argc /= 0) . fail . unlines $ ["summ does not expect arguments." ,"It reads numbers from stdin and finally prints the sum"] print . sum -- sum them up . map readI -- turns numbers into integers . concatMap words -- split words . lines -- split lines =<< getContents -- reads stdin where readI :: String -> Integer readI = read