Safe Haskell | Safe-Infered |
---|
- data Parser a
- liftOpt :: Option r a -> Parser a
- data ParserInfo a = ParserInfo {}
- evalParser :: Parser a -> Maybe a
- runParser :: Parser a -> [String] -> Maybe (a, [String])
- mapParser :: (forall r x. Option r x -> b) -> Parser a -> [b]
- optionNames :: OptReader a -> [OptName]
Option parsers
A Parser
is composed of a list of options. Several kinds of options
are supported:
- Flags: simple no-argument options. When a flag is encountered on the command line, its value is returned.
- Options: options with an argument. An option can define a reader, which converts its argument from String to the desired value, or throws a parse error if the argument does not validate correctly.
- Arguments: positional arguments, validated in the same way as option arguments.
- Commands. A command defines a completely independent sub-parser. When a command is encountered, the whole command line is passed to the corresponding parser.
A Parser a
is an option parser returning a value of type a
.
Program descriptions
data ParserInfo a Source
A full description for a runnable Parser
for a program.
ParserInfo | |
|
Running parsers
evalParser :: Parser a -> Maybe aSource
Low-level utilities
mapParser :: (forall r x. Option r x -> b) -> Parser a -> [b]Source
Map a polymorphic function over all the options of a parser, and collect the results.
optionNames :: OptReader a -> [OptName]Source