| I have a little problem with the "getArgs" function in Hugs/GHC.
| Something like
|  
| > import System
| >
| > main = do argv <- getArgs
| >                    print argv
|  
| prints "[]" (the empty list) and not the list of arguments.
| Since this is definitely not the right behaviour, I must be
| making a mistake.
| I'm using GHC-4.03 and Hugs98 on Windows 98.

As it says in the Hugs manual:

  When using getArgs, only the stand-alone system passes arguments to the
  executing program. The interactive system always uses an empty argument
  list when runnning a program.

In other words, if you run a program from the interpreter, there isn't
any way to pass command line arguments (it certainly wouldn't make sense
to grab the command line arguments that were passed to Hugs, for example).
But command line arguments are available in programs executed using
runhugs.

If this is a problem, you might considering structuring your code something
like:

   main = do argv <- getArgs
             begin argv

   begin :: [String] -> IO ()
   begin  = ... rest of your code here ...

Now you can call begin during interactive sessions with an extra parameter
to pass in the command line args.

All the best,
Mark



Reply via email to