Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
a miniaml set of
Synopsis
- opts2 :: Parser a -> Text -> Text -> ParserInfo a
- (<>) :: Semigroup a => a -> a -> a
- (<*>) :: Applicative f => f (a -> b) -> f a -> f b
- data Parser a
- switch :: Mod FlagFields Bool -> Parser Bool
- long :: forall (f :: Type -> Type) a. HasName f => String -> Mod f a
- short :: forall (f :: Type -> Type) a. HasName f => Char -> Mod f a
- help :: forall (f :: Type -> Type) a. String -> Mod f a
- metavar :: forall (f :: Type -> Type) a. HasMetavar f => String -> Mod f a
- argument :: ReadM a -> Mod ArgumentFields a -> Parser a
- str :: IsString s => ReadM s
- strOption :: IsString s => Mod OptionFields s -> Parser s
- value :: forall (f :: Type -> Type) a. HasValue f => a -> Mod f a
- header :: String -> InfoMod a
- helper :: Parser (a -> a)
- fullDesc :: InfoMod a
- progDesc :: String -> InfoMod a
- info :: Parser a -> InfoMod a -> ParserInfo a
- execParser :: ParserInfo a -> IO a
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
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
A Parser a
is an option parser returning a value of type a
.
Instances
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.
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.
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.
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
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.