This more of a style question, rather than a how to.
So I\'ve got a program that needs two command line arguments: a string and an integer.
I implemented it this
There are plenty of argument/option parsing libraries in Haskell that make life easier than with read
/getOpt
, an example with a modern one (optparse-applicative) might be of interest:
import Options.Applicative
doStuffWith :: String -> Int -> IO ()
doStuffWith s n = mapM_ putStrLn $ replicate n s
parser = fmap (,)
(argument str (metavar "")) <*>
(argument auto (metavar ""))
main = execParser (info parser fullDesc) >>= (uncurry doStuffWith)