uniform-cmdLineArgs-0.1.5.1: a convenient handling of command line arguments
Safe HaskellSafe-Inferred
LanguageHaskell2010

Uniform.CmdLineArgs

Description

a miniaml set of

Synopsis

Documentation

(<>) :: Semigroup a => a -> a -> a infixr 6 #

An associative operation.

>>> [1,2,3] <> [4,5,6]
[1,2,3,4,5,6]

(<*>) :: Applicative f => f (a -> b) -> f a -> f b infixl 4 #

Sequential application.

A few functors support an implementation of <*> that is more efficient than the default one.

Example

Expand

Used in combination with (<$>), (<*>) can be used to build a record.

>>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>> produceFoo :: Applicative f => f Foo
>>> produceBar :: Applicative f => f Bar
>>> produceBaz :: Applicative f => f Baz
>>> mkState :: Applicative f => f MyState
>>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz

data Parser a #

A Parser a is an option parser returning a value of type a.

Instances

Instances details
Alternative Parser 
Instance details

Defined in Options.Applicative.Types

Methods

empty :: Parser a #

(<|>) :: Parser a -> Parser a -> Parser a #

some :: Parser a -> Parser [a] #

many :: Parser a -> Parser [a] #

Applicative Parser 
Instance details

Defined in Options.Applicative.Types

Methods

pure :: a -> Parser a #

(<*>) :: Parser (a -> b) -> Parser a -> Parser b #

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c #

(*>) :: Parser a -> Parser b -> Parser b #

(<*) :: Parser a -> Parser b -> Parser a #

Functor Parser 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> Parser a -> Parser b #

(<$) :: a -> Parser b -> Parser a #

switch :: Mod FlagFields Bool -> Parser Bool #

Builder for a boolean flag.

Note: Because this parser will never fail, it can not be used with combinators such as some or many, as these combinators continue until a failure occurs. See flag'.

switch = flag False True

long :: forall (f :: Type -> Type) a. HasName f => String -> Mod f a #

Specify a long name for an option.

short :: forall (f :: Type -> Type) a. HasName f => Char -> Mod f a #

Specify a short name for an option.

help :: forall (f :: Type -> Type) a. String -> Mod f a #

Specify the help text for an option.

metavar :: forall (f :: Type -> Type) a. HasMetavar f => String -> Mod f a #

Specify a metavariable for the argument.

Metavariables have no effect on the actual parser, and only serve to specify the symbolic name for an argument to be displayed in the help text.

argument :: ReadM a -> Mod ArgumentFields a -> Parser a #

Builder for an argument parser.

str :: IsString s => ReadM s #

String Option reader.

Polymorphic over the IsString type class since 0.14.

strOption :: IsString s => Mod OptionFields s -> Parser s #

Builder for an option taking a String argument.

value :: forall (f :: Type -> Type) a. HasValue f => a -> Mod f a #

Specify a default value for an option.

Note: Because this modifier means the parser will never fail, do not use it with combinators such as some or many, as these combinators continue until a failure occurs. Careless use will thus result in a hang.

To display the default value, combine with showDefault or showDefaultWith.

header :: String -> InfoMod a #

Specify a header for this parser.

helper :: Parser (a -> a) #

A hidden "helper" option which always fails.

A common usage pattern is to apply this applicatively when creating a ParserInfo

opts :: ParserInfo Sample
opts = info (sample <**> helper) mempty

fullDesc :: InfoMod a #

Show a full description in the help text of this parser (default).

progDesc :: String -> InfoMod a #

Specify a short program description.

info :: Parser a -> InfoMod a -> ParserInfo a #

Create a ParserInfo given a Parser and a modifier.

execParser :: ParserInfo a -> IO a #

Run a program description.

Parse command line arguments. Display help text and exit if any parse error occurs.