Haskell by Example: Command-Line Arguments

original
import System.Environment

main = do
    args <- getArgs
    let arg = args !! 3

    print args
    putStrLn arg

    progName <- getProgName
    putStrLn progName
$ ghc command-line-arguments.hs -o command-line-arguments
$ ./command-line-arguments a b c d
["a","b","c","d"]
d
command-line-arguments
back to index