import Data.Char (isDigit) import System.Environment (getArgs) import System.IO (hPutStr,stderr) import System.Exit (exitFailure) nest :: Int -> String -> String nest i = unlines . map (s++) . lines where s = replicate i ' ' main :: IO () main = do args <- getArgs case args of [arg] | all isDigit arg -> putStr . nest (read arg) =<< getContents _ -> do hPutStr stderr . unlines $ ["Usage: nest " ,"" ,"This program will write on standard output the contents" ,"read on standard input but nested by spaces." ,"" ,"Each gets indented by spaces more." ] exitFailure