Program Command Line Arguments

My apologies if this is a question with a trivial answer. Command line args in C are accessed via argc and argv[] defined as arguments to main();. How are command line arguments to a ghc-compiled program accessed in Haskell? Or is that even possible? Thanks.

On Mar 10, 2007, at 20:46 , Dave@haskell.org, Feustel@haskell.org wrote:
My apologies if this is a question with a trivial answer. Command line args in C are accessed via argc and argv[] defined as arguments to main();.
How are command line arguments to a ghc-compiled program accessed in Haskell? Or is that even possible?
Take a look at the System.Environment module. -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Dave:
My apologies if this is a question with a trivial answer. Command line args in C are accessed via argc and argv[] defined as arguments to main();.
How are command line arguments to a ghc-compiled program accessed in Haskell? Or is that even possible?
Simplest: System.Environment:getArgs import System.Environment main = do args <- getArgs print args http://haskell.org/ghc/docs/latest/html/libraries/base/System-Environment.ht... Complex: System.Console.GetOpt Example here: http://cgi.cse.unsw.edu.au/~dons/blog/2006/12/18#ph-3 http://haskell.org/ghc/docs/latest/html/libraries/base/System-Console-GetOpt... You can find these functions yourself with hoogle: http://haskell.org/hoogle/ Searching for 'args' returns: System. getArgs :: IO [String] Cheers, Don P.S. This question is best asked on #haskell possibly (http://haskell.org/haskellwiki/IRC_channel)
participants (3)
-
unknown@example.com
-
Brandon S. Allbery KF8NH
-
dons@cse.unsw.edu.au