The options package

[ Tags: console, library, mit ] [ Propose Tags ]

The options package lets library and application developers easily work with command-line options.

The following example is a full program that can accept two options, --message and --quiet:

{-# LANGUAGE TemplateHaskell #-}

import Options

defineOptions "MainOptions" $ do
    stringOption "optMessage" "message" "Hello world!"
        "A message to show the user."
    boolOption "optQuiet" "quiet" False
        "Whether to be quiet."
main :: IO ()
main = runCommand $ \opts args -> do
    if optQuiet opts
        then return ()
        else putStrLn (optMessage opts)
$ ./hello
Hello world!
$ ./hello --message='ciao mondo'
ciao mondo
$ ./hello --quiet

In addition, this library will automatically create documentation options such as --help and --help-all:

$ ./hello --help
Help Options:
  -h, --help                  Show option summary.
  --help-all                  Show all help options.

Application Options:
  --message                   A message to show the user.
  --quiet                     Whether to be quiet.


Versions 0.1, 0.1.1, 1.0, 1.1, 1.2, 1.2.1,
Dependencies base (>=4.0 && <4.8), bytestring (==0.9.*), containers (>=0.1 && <0.5), monads-tf, system-filepath (==0.4.*), template-haskell, text (>=0.7 && <0.12), transformers (==0.2.*) [details]
License MIT
Author John Millikin <>
Maintainer John Millikin <>
Category Console
Home page
Bug tracker
Source repository head: bzr branch
this: bzr branch -r haskell-options_0.1
Uploaded Sat Mar 24 19:07:23 UTC 2012 by JohnMillikin
Updated Mon Dec 29 11:22:03 UTC 2014 by HerbertValerioRiedel to revision 1
Distributions Debian:, LTSHaskell:, NixOS:, Stackage:, Tumbleweed:
Downloads 4495 total (66 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees