Safe Haskell | Safe-Infered |
---|
- class ArgVal a where
- parser :: ArgParser a
- pp :: ArgPrinter a
- type ArgParser a = String -> Either Doc a
- type ArgPrinter a = a -> Doc
- fromParsec :: (String -> Doc) -> Parsec String () a -> ArgParser a
- enum :: [(String, a)] -> ArgParser a
- just :: ArgVal a => ArgParser (Maybe a)
- maybePP :: ArgVal a => ArgPrinter (Maybe a)
- list :: ArgVal a => Char -> ArgParser [a]
- listPP :: ArgVal a => Char -> ArgPrinter [a]
- pair :: (ArgVal a, ArgVal b) => Char -> ArgParser (a, b)
- pairPP :: (ArgVal a, ArgVal b) => Char -> ArgPrinter (a, b)
- triple :: (ArgVal a, ArgVal b, ArgVal c) => Char -> ArgParser (a, b, c)
- triplePP :: (ArgVal a, ArgVal b, ArgVal c) => Char -> ArgPrinter (a, b, c)
- quadruple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d) => Char -> ArgParser (a, b, c, d)
- quadruplePP :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d) => Char -> ArgPrinter (a, b, c, d)
- quintuple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> ArgParser (a, b, c, d, e)
- quintuplePP :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> ArgPrinter (a, b, c, d, e)
Parsing values from the command line
The class of values that can be parsed from the command line. Instances
must provide both parser
and pp
.
:: ArgParser a | A parser of instance values. |
:: ArgPrinter a | A pretty printer for instance values. |
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) |
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.
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 :: [(String, a)] -> ArgParser aSource
A parser of enumerated values conveyed as an association list of
( string, value )
pairs. Unambiguous prefixes of string
map to
value
.
Maybe values
maybePP :: ArgVal a => ArgPrinter (Maybe a)Source
List values
listPP :: ArgVal a => Char -> ArgPrinter [a]Source
Tuple values
quadruplePP :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d) => Char -> ArgPrinter (a, b, c, d)Source
creates a pretty printer of quadruples of quadruplePP
sepArgVal
instances separated by sep
quintuple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> ArgParser (a, b, c, d, e)Source
quintuplePP :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> ArgPrinter (a, b, c, d, e)Source
creates a pretty printer of quintuples of quintuplePP
sepArgVal
instances separated by sep