20100112

using the parseargs package

This week I found the parseargs package in Hackage to be useful. It makes handling command-line arguments for your program easy, and gives the user a very pleasant command-line interface to your program.
However, I also needed to use the command line options for the GHC runtime system in my compiled program.
The important thing to note (which I missed on a first sleepy reading) is this:

When your Haskell program starts up, its RTS extracts command-line arguments bracketed between +RTS and -RTS as its own. For example:

% ./a.out -f +RTS -p -S -RTS -h foo bar 

The RTS will snaffle -p -S for itself, and the remaining arguments -f -h foo bar will be handed to your program if/when it calls System.getArgs.

If you do that, then you can use the command line arguments for the RTS along with whatever you have written into your program.

No comments: