Extensible options. They are used for provider-specific settings, ingredient-specific settings and core settings (such as the test name pattern).
- class Typeable v => IsOption v where
- data OptionSet
- setOption :: IsOption v => v -> OptionSet -> OptionSet
- changeOption :: forall v. IsOption v => (v -> v) -> OptionSet -> OptionSet
- lookupOption :: forall v. IsOption v => OptionSet -> v
- singleOption :: IsOption v => v -> OptionSet
- data OptionDescription where
- flagCLParser :: forall v. IsOption v => Maybe Char -> v -> Parser v
- safeRead :: Read a => String -> Maybe a
An option is a data type that inhabits the
IsOption type class.
The value to use if the option was not supplied explicitly
Try to parse an option value from a string
The option name. It is used to form the command line option name, for instance. Therefore, it had better not contain spaces or other fancy characters. It is recommended to use dashes instead of spaces.
The option description or help string. This can be an arbitrary string.
A command-line option parser.
It has a default implementation in terms of the other methods. You may want to override it in some cases (e.g. add a short flag).
Even if you override this, you still should implement all the methods above, to allow alternative interfaces.
Do not supply a default value here for this parser! This is because if no value was provided on the command line we may lookup the option e.g. in the environment. But if the parser always succeeds, we have no way to tell whether the user really provided the option on the command line.
Option sets and operations
A set of options. Only one option of each type can be kept.
If some option has not been explicitly set, the default value is used.
Change the option value
The purpose of this data type is to capture the dictionary corresponding to a particular option.
|:: forall v . IsOption v|
|=> Maybe Char|
optional short flag
non-default value (when the flag is supplied)
|-> Parser v|
Command-line parser to use with flags