How to Read Program Arguments in Haskell
This is the one programming language to date where I have had the hardest time doing the little hello world program that prints a hello line per input argument.
Like in most modern languages arguments are behind a function call, and the hardest part for me was not finding out how to do this. The hardest part was to wrap my head around how haskell works. The program is just as concise as most of the other examples - but it took some time to get it right.
module Main( main ) where import System.Environment( getArgs ) hello x = putStrLn ("Hello " ++ x) main = do args <- getArgs mapM_ hello args
Compile the program with
ghc -o test test.hs and run it like with all the other hello world programs.