[Haskell-cafe] 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. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Program Command Line Arguments
On Mar 10, 2007, at 20:46 , [EMAIL PROTECTED], [EMAIL PROTECTED] 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] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Program Command Line Arguments
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.html 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.html 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) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe