Search code examples
haskellgetopt

Haskell - using getOpt to parse arguments, why does ReqArg take multiple Arguments?


I got an argument parser working using getOpt which is great, but I do have one question. When using ReqArg in an option like:

Option ['c'] ["config"] (ReqArg (\f opts -> opts { configFile = f }) "FILE")
                     "use a custom configuration file"

what does it use that second argument for (in this case, "FILE")? I have not experienced any kind of difference in behavior when specifying another string.


Solution

  • It's for the auto-generated usage message. Same with OptArg. Run usageInfo on your OptDescr list and see what comes back.