HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

ModuleAgda-2.8.0.2Haskell2010

Agda.Utils.GetOpt

This module provides facilities for parsing the command-line options in a standalone program. It is essentially a Haskell port of the GNU getopt library.

It is a fork of System.Console.GetOpt from the base package of GHC, written by Sven Panne.

We modify it to remove the "allow prefixes of long options" behavior.

  • 3 types
  • 3 values
  • PackageAgda-2.8.0.2
  • Exports6
  • LanguageHaskell2010
  • LicenceMIT
  • SourceGetOpt.hs

GetOpt

6 declarations
valuegetOpt
  1. :: ArgOrder a

    non-option handling

  2. -> [OptDescr a]

    option descriptors

  3. -> [String]

    the command-line arguments

  4. -> ([a], [String], [String])
    (options, non-options, error messages)
#

Process the command-line, and return the list of values that matched (and those that didn't). The arguments are:

  • The order requirements (see ArgOrder)

  • The option descriptions (see OptDescr)

  • The actual command line arguments (presumably got from getArgs).

getOpt returns a triple consisting of the option arguments, a list of non-options, and a list of error messages.

valuegetOpt'
  1. :: ArgOrder a

    non-option handling

  2. -> [OptDescr a]

    option descriptors

  3. -> [String]

    the command-line arguments

  4. -> ([a], [String], [String], [String])
    (options, non-options, unrecognized, error messages)
#

This is almost the same as getOpt, but returns a quadruple consisting of the option arguments, a list of non-options, a list of unrecognized options, and a list of error messages.

valueusageInfo
  1. :: String

    header

  2. -> [OptDescr a]

    option descriptors

  3. -> String

    nicely formatted description of options

#

Return a string describing the usage of a command, derived from the header (first argument) and the options described by the second argument.

datadata ArgOrder a
#

What to do with options following non-options.

Constructors

Instances1Functor
datadata OptDescr a
#

Each OptDescr describes a single option.

The arguments to Option are:

  • list of short option characters

  • list of long option strings (without "--")

  • argument descriptor

  • explanation of option for user

Constructors

Instances1Functor
datadata ArgDescr a
#

Describes whether an option takes an argument or not, and if so how the argument is injected into a value of type a.

Constructors

Instances1Functor