sbergot / ArgParser

BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

`Maybe a` instance of RawRead #7

Open SamProtas opened 7 years ago

SamProtas commented 7 years ago

This PR provides the ability to use Maybe a types in the datatype target of parsing. This is particularly useful for optional arguments that don't have a natural "default".

Imagine an --limit flag argument where the application operates "unbounded" if no limit is provided. You could use -1 as a default (or some other magic number) to fake this behavior, but using Maybe Int is much cleaner.

Currently this functionality requires creating a custom Argument with a custom parser. This seems like a reasonably common case for a command line application so I'd like to add first class support for it.