ReadArgs-1.2.3: Simple command line argument parsing

Safe HaskellSafe
LanguageHaskell98

ReadArgs

Synopsis

Documentation

readArgs :: ArgumentTuple a => IO a Source #

parse the desired argument tuple from the command line or print a simple usage statment and quit

readArgsFrom :: ArgumentTuple a => [String] -> IO a Source #

read args from the given strings or print a simple usage statment and quit (so you can do option parsing first)

class Arguable a where Source #

a class for types that can be parsed from exactly one command line argument

Minimal complete definition

parse, name

Methods

parse :: String -> Maybe a Source #

name :: a -> String Source #

name's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument

Instances

Arguable Char Source #

char is a special case, so that we don't force the user to single-quote their input

(Typeable * t, Read t) => Arguable t Source #

all types that are typeable and readable can be used as simple arguments

Methods

parse :: String -> Maybe t Source #

name :: t -> String Source #

Arguable String Source #

string is a special case, so that we don't force the user to double-quote their input

Arguable Text Source #

Text is a special case, so that we don't force the user to double-quote their input

Arguable FilePath Source #

FilePath is a special case, so that we don't force the user to double-quote their input

class Argument a where Source #

a class for types that can be parsed from some number of command line arguments

Minimal complete definition

parseArg, argName

Methods

parseArg :: [String] -> [(a, [String])] Source #

argName :: a -> String Source #

argName's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument

Instances

Arguable a => Argument a Source #

use the arguable tyep to just parse a single argument

Methods

parseArg :: [String] -> [(a, [String])] Source #

argName :: a -> String Source #

Argument String Source #

make sure strings are handled as a separate type, not a list of chars

Arguable a => Argument [a] Source #

use a list when it should be parsed from zero or more (greedily)

Methods

parseArg :: [String] -> [([a], [String])] Source #

argName :: [a] -> String Source #

Arguable a => Argument (Maybe a) Source #

use Maybe when it should be parsed from one or zero (greedily)

Methods

parseArg :: [String] -> [(Maybe a, [String])] Source #

argName :: Maybe a -> String Source #

Argument (m a) => Argument (NonGreedy m a) Source #

use NonGreedy when it should be parsed non-greedily (e.g. (NonGreedy xs :: NonGreedy [] Int, x :: Maybe Float) <- readArgs)

Methods

parseArg :: [String] -> [(NonGreedy m a, [String])] Source #

argName :: NonGreedy m a -> String Source #

newtype NonGreedy m a Source #

a wrapper type to indicate a non-greedy list or maybe

Constructors

NonGreedy 

Fields

Instances

Eq (m a) => Eq (NonGreedy m a) Source # 

Methods

(==) :: NonGreedy m a -> NonGreedy m a -> Bool #

(/=) :: NonGreedy m a -> NonGreedy m a -> Bool #

Show (m a) => Show (NonGreedy m a) Source # 

Methods

showsPrec :: Int -> NonGreedy m a -> ShowS #

show :: NonGreedy m a -> String #

showList :: [NonGreedy m a] -> ShowS #

Argument (m a) => Argument (NonGreedy m a) Source #

use NonGreedy when it should be parsed non-greedily (e.g. (NonGreedy xs :: NonGreedy [] Int, x :: Maybe Float) <- readArgs)

Methods

parseArg :: [String] -> [(NonGreedy m a, [String])] Source #

argName :: NonGreedy m a -> String Source #

class ArgumentTuple a where Source #

a class for tuples of types that can be parsed from the entire list of arguments

Minimal complete definition

parseArgsFrom, usageFor

Methods

parseArgsFrom :: [String] -> Maybe a Source #

usageFor :: a -> String Source #

usageFor's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument

Instances

ArgumentTuple () Source #

use () for no arguments

Argument a => ArgumentTuple a Source # 
(Argument b, Argument a) => ArgumentTuple (b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (b, a) Source #

usageFor :: (b, a) -> String Source #

(Argument a, ArgumentTuple y) => ArgumentTuple ((:&) a y) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (a :& y) Source #

usageFor :: (a :& y) -> String Source #

(Argument c, Argument b, Argument a) => ArgumentTuple (c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (c, b, a) Source #

usageFor :: (c, b, a) -> String Source #

(Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (d, c, b, a) Source #

usageFor :: (d, c, b, a) -> String Source #

(Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (e, d, c, b, a) Source #

usageFor :: (e, d, c, b, a) -> String Source #

(Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (f, e, d, c, b, a) Source #

usageFor :: (f, e, d, c, b, a) -> String Source #

(Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (g, f, e, d, c, b, a) Source #

usageFor :: (g, f, e, d, c, b, a) -> String Source #

(Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (h, g, f, e, d, c, b, a) Source #

usageFor :: (h, g, f, e, d, c, b, a) -> String Source #

(Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (i, h, g, f, e, d, c, b, a) Source #

usageFor :: (i, h, g, f, e, d, c, b, a) -> String Source #

(Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (j, i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (j, i, h, g, f, e, d, c, b, a) Source #

usageFor :: (j, i, h, g, f, e, d, c, b, a) -> String Source #

(Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (k, j, i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (k, j, i, h, g, f, e, d, c, b, a) Source #

usageFor :: (k, j, i, h, g, f, e, d, c, b, a) -> String Source #

(Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (l, k, j, i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (l, k, j, i, h, g, f, e, d, c, b, a) Source #

usageFor :: (l, k, j, i, h, g, f, e, d, c, b, a) -> String Source #

(Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (m, l, k, j, i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (m, l, k, j, i, h, g, f, e, d, c, b, a) Source #

usageFor :: (m, l, k, j, i, h, g, f, e, d, c, b, a) -> String Source #

(Argument n, Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (n, m, l, k, j, i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (n, m, l, k, j, i, h, g, f, e, d, c, b, a) Source #

usageFor :: (n, m, l, k, j, i, h, g, f, e, d, c, b, a) -> String Source #

(Argument o, Argument n, Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (o, n, m, l, k, j, i, h, g, f, e, d, c, b, a) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (o, n, m, l, k, j, i, h, g, f, e, d, c, b, a) Source #

usageFor :: (o, n, m, l, k, j, i, h, g, f, e, d, c, b, a) -> String Source #

data a :& b infixr 5 Source #

use :& to construct arbitrary length tuples of any parsable arguments

Constructors

a :& b infixr 5 

Instances

(Eq b, Eq a) => Eq ((:&) a b) Source # 

Methods

(==) :: (a :& b) -> (a :& b) -> Bool #

(/=) :: (a :& b) -> (a :& b) -> Bool #

(Show b, Show a) => Show ((:&) a b) Source # 

Methods

showsPrec :: Int -> (a :& b) -> ShowS #

show :: (a :& b) -> String #

showList :: [a :& b] -> ShowS #

(Argument a, ArgumentTuple y) => ArgumentTuple ((:&) a y) Source # 

Methods

parseArgsFrom :: [String] -> Maybe (a :& y) Source #

usageFor :: (a :& y) -> String Source #