Safe Haskell | Safe-Infered |
---|
- type ArgParser a = String -> Either Doc a
- type ArgPrinter a = a -> Doc
- type Converter a = (ArgParser a, ArgPrinter a)
- class ArgVal a where
- pp :: ArgVal a => ArgPrinter a
- parser :: ArgVal a => ArgParser a
- fromParsec :: (String -> Doc) -> Parsec String () a -> ArgParser a
- enum :: Eq a => [(String, a)] -> Converter a
- just :: ArgVal a => Converter (Maybe a)
- list :: ArgVal a => Char -> Converter [a]
- pair :: (ArgVal a, ArgVal b) => Char -> Converter (a, b)
- triple :: (ArgVal a, ArgVal b, ArgVal c) => Char -> Converter (a, b, c)
- quadruple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d) => Char -> Converter (a, b, c, d)
- quintuple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> Converter (a, b, c, d, e)
Parsing values from the command line
type ArgParser a = String -> Either Doc aSource
The type of parsers of individual command line argument values.
type ArgPrinter a = a -> DocSource
The type of printers of values retrieved from the command line.
type Converter a = (ArgParser a, ArgPrinter a)Source
A converter is just a pair of a parser and a printer.
The class of values that can be converted from the command line.
ArgVal Bool | |
ArgVal Double | |
ArgVal Float | |
ArgVal Int | |
ArgVal Integer | |
ArgVal HelpFormat | |
ArgVal [Char] | |
ArgVal (Ratio Integer) | |
ArgVal (Maybe Bool) | |
ArgVal (Maybe Double) | |
ArgVal (Maybe Float) | |
ArgVal (Maybe Int) | |
ArgVal (Maybe Integer) | |
ArgVal (Maybe [Char]) | |
ArgVal (Maybe (Ratio Integer)) | |
ArgVal (Maybe HelpFormat) |
pp :: ArgVal a => ArgPrinter aSource
The pretty printing part of a converter
.
Helpers for instantiating ArgVal
fromParsec :: (String -> Doc) -> Parsec String () a -> ArgParser aSource
fromParsec
onErr p
makes an ArgParser
from p
using onErr
to
produce meaningful error messages. On failure, onErr
will receive a
raw string of the value found on the command line.
enum :: Eq a => [(String, a)] -> Converter aSource
A converter of enumerated values conveyed as an association list of
( string, value )
pairs. Unambiguous prefixes of string
map to
value
.