cmdtheline-0.1.0.0: Declaritive command-line option parsing and documentation library.

Safe HaskellSafe-Infered

System.Console.CmdTheLine.ArgVal

Contents

Synopsis

Parsing values from the command line

class ArgVal a whereSource

The class of values that can be parsed from the command line. Instances must provide both parser and pp.

Methods

parserSource

Arguments

:: ArgParser a

A parser of instance values.

ppSource

Arguments

:: ArgPrinter a

A pretty printer for instance values.

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

just :: ArgVal a => ArgParser (Maybe a)Source

A parser of Maybe values of ArgVal instances. A convenient default that merely lifts the ArgVal instance's parsed value with Just.

maybePP :: ArgVal a => ArgPrinter (Maybe a)Source

A printer of Maybe values of ArgVal instances. A convenient default that prints nothing on the Nothing and just the value on the Just.

List values

list :: ArgVal a => Char -> ArgParser [a]Source

list sep creates a parser of lists of an ArgVal instance separated by sep.

listPP :: ArgVal a => Char -> ArgPrinter [a]Source

listPP sep creates a pretty printer of lists of an ArgVal instance seperated by sep.

Tuple values

pair :: (ArgVal a, ArgVal b) => Char -> ArgParser (a, b)Source

pair sep creates a parser of pairs of ArgVal instances separated by sep.

pairPP :: (ArgVal a, ArgVal b) => Char -> ArgPrinter (a, b)Source

pairPP sep creates a pretty printer of pairs of ArgVal instances separated by sep

triple :: (ArgVal a, ArgVal b, ArgVal c) => Char -> ArgParser (a, b, c)Source

triple sep creates a parser of triples of ArgVal instances separated by sep.

triplePP :: (ArgVal a, ArgVal b, ArgVal c) => Char -> ArgPrinter (a, b, c)Source

triplePP sep creates a pretty printer of triples of ArgVal instances separated by sep

quadruple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d) => Char -> ArgParser (a, b, c, d)Source

quadruple sep creates a parser of quadruples of ArgVal instances separated by sep.

quadruplePP :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d) => Char -> ArgPrinter (a, b, c, d)Source

quadruplePP sep creates a pretty printer of quadruples of ArgVal instances separated by sep

quintuple :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> ArgParser (a, b, c, d, e)Source

quintuple sep creates a parser of quintuples of ArgVal instances separated by sep.

quintuplePP :: (ArgVal a, ArgVal b, ArgVal c, ArgVal d, ArgVal e) => Char -> ArgPrinter (a, b, c, d, e)Source

quintuplePP sep creates a pretty printer of quintuples of ArgVal instances separated by sep