HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleoptparse-applicative-0.18.1.0Haskell98

Options.Applicative.Common

  • 3 types
  • 10 values

Option parsers

3 declarations

A Parser is composed of a list of options. Several kinds of options are supported:

  • Flags: simple no-argument options. When a flag is encountered on the command line, its value is returned.

  • Options: options with an argument. An option can define a reader, which converts its argument from String to the desired value, or throws a parse error if the argument does not validate correctly.

  • Arguments: positional arguments, validated in the same way as option arguments.

  • Commands. A command defines a completely independent sub-parser. When a command is encountered, the whole command line is passed to the corresponding parser.

datadata Parser a
#

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

Instances3Functor, Applicative, Alternative
  • Functor ParserDefined in optparse-applicative-0.18.1.0 · Options.Applicative.Types
  • Applicative ParserDefined in optparse-applicative-0.18.1.0 · Options.Applicative.Types
  • Alternative ParserDefined in optparse-applicative-0.18.1.0 · Options.Applicative.Types

Program descriptions

2 declarations
datadata ParserInfo a
#

A full description for a runnable Parser for a program.

Constructors

Instances1Functor
  • Functor ParserInfoDefined in optparse-applicative-0.18.1.0 · Options.Applicative.Types
datadata ParserPrefs
#

Global preferences for a top-level Parser.

Constructors

Instances2Eq, Show
  • Eq ParserPrefsDefined in optparse-applicative-0.18.1.0 · Options.Applicative.Types
  • Show ParserPrefsDefined in optparse-applicative-0.18.1.0 · Options.Applicative.Types

Running parsers

5 declarations
valuerunParser
  1. :: MonadP m
  2. => ArgPolicy
  3. -> IsCmdStart
  4. -> Parser a
  5. -> Args
  6. -> m (a, Args)
#

Apply a Parser to a command line, and return a result and leftover arguments. This function returns an error if any parsing error occurs, or if any options are missing and don't have a default value.

valueevalParser :: Parser a -> Maybe a
#

The default value of a Parser. This function returns an error if any of the options don't have a default value.

Low-level utilities

3 declarations