Safe Haskell | None |
---|
ReadArgs
- readArgs :: ArgumentTuple a => IO a
- readArgsFrom :: ArgumentTuple a => [String] -> IO a
- class Arguable a where
- class Argument a where
- newtype NonGreedy m a = NonGreedy {
- unNonGreedy :: m a
- class ArgumentTuple a where
- parseArgsFrom :: [String] -> Maybe a
- usageFor :: a -> String
- data a :& b = a :& b
Documentation
readArgs :: ArgumentTuple a => IO a
parse the desired argument tuple from the command line or print a simple usage statment and quit
readArgsFrom :: ArgumentTuple a => [String] -> IO a
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
a class for types that can be parsed from exactly one command line argument
Methods
name's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument
Instances
Arguable Char | char is a special case, so that we don't force the user to single-quote their input |
Arguable String | string is a special case, so that we don't force the user to double-quote their input |
(Typeable t, Read t) => Arguable t | all types that are typeable and readable can be used as simple arguments |
Arguable Text | Text is a special case, so that we don't force the user to double-quote their input |
Arguable FilePath | FilePath is a special case, so that we don't force the user to double-quote their input |
class Argument a where
a class for types that can be parsed from some number of command line arguments
Methods
parseArg :: [String] -> [(a, [String])]
argName's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument
Instances
Argument String | make sure strings are handled as a separate type, not a list of chars |
Arguable a => Argument a | use the arguable tyep to just parse a single argument |
Arguable a => Argument [a] | use a list when it should be parsed from zero or more (greedily) |
Arguable a => Argument (Maybe a) | use Maybe when it should be parsed from one or zero (greedily) |
Argument (m a) => Argument (NonGreedy m a) | use NonGreedy when it should be parsed non-greedily
(e.g. |
newtype NonGreedy m a
a wrapper type to indicate a non-greedy list or maybe
Constructors
NonGreedy | |
Fields
|
class ArgumentTuple a where
a class for tuples of types that can be parsed from the entire list of arguments
Methods
parseArgsFrom :: [String] -> Maybe a
usageFor's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument
Instances