#!/usr/bin/runhugs module Main(main) where import System(getArgs) main :: IO () main = do args <- getArgs if null args then catFiles ["-"] else catFiles args catFiles :: [String] -> IO () catFiles xs = sequence_ [ catFile x | x <- xs] catFile :: String -> IO () catFile "-" = do input <- getContents putStr input catFile x = do contents <- catch (readFile x) (\_ -> return (msg ++ x ++ "\n")) putStr contents where msg = "ERROR reading file: "