Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (20 sloc) 503 Bytes
import Control.Monad (replicateM_)
import System.IO (readLn)
import System.Environment (getArgs)
-- implement unix cat command
main = do
args <- getArgs
case args of
[path] -> do
contents <- readFile path
putStrLn contents
_ -> do
putStrLn "Usage: cat ./path/to/file.abc"
-- print out message N times
message :: IO ()
message = do
putStrLn "Type message:"
msg <- getLine
putStrLn "Type # times:"
n <- readLn
replicateM_ n (putStrLn msg)