
You can use http://hackage.haskell.org/package/uu-options, designed to parser command line options. It even allows for combining various elements on the command line into a single option field.
See the second half of the paper mentioned on hackage for examples of its use.
Since the parsers make use of uu-parsinglib the user gets "autocorrection" and nice error messages for free.
Doaitse
On 28 Jun 2014, at 21:28 , Johan Larson
I've been looking at choices for parsing command line arguments, including getOpt. The examples I can find focus on string arguments, whereas I am interested in numbers. In the application at hand, it is particularly important to issue clear error messages when arguments don't parse as numbers or are out of range.
I could use getOpt as a first pass with string arguments and then turn the strings into validated numbers in a second pass, but that's a bit awkward. Alternately I could use the options records with Options -> IO Options functions. But both of these solutions treat type mismatches differently from other options errors.
Has anyone found a cleaner solution?
-- Johan Larson -- Toronto, Canada _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe