lambda-options: A modern command-line parser for Haskell.

[ bsd2, library, text ] [ Propose Tags ]

A modern command-line parser for Haskell.

[Skip to Readme]
Dependencies base (==4.7.*), containers (==0.5.*), mtl (==2.2.*), read-bounded (==0.1.*) [details]
License LicenseRef-OtherLicense
Author Thomas Eding
Category Text
Home page
Uploaded by ThomasEding at Sat Jul 25 15:27:26 UTC 2015
Distributions NixOS:
Downloads 3392 total (36 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for lambda-options-

[back to package description]


A modern command-line parser for Haskell.

  • Easy to use. The API is expressive.
  • Easy to learn. The API is tiny and simple.
  • BSD 1-Clause License -------------- Basic example:
import System.Environment
import Text.LambdaOptions

options :: Options IO () ()
options = do
    addOption (kw ["--help", "-h"] `text` "Display this help text.") $ \(HelpDescription desc) -> do
        putStrLn "Usage:"
        putStrLn desc
    addOption (kw "--user" `argText` "NAME" `text` "Prints name.") $ \name -> do
        putStrLn $ "Name:" ++ name
    addOption (kw "--user" `argText` "NAME AGE" `text` "Prints name and age.") $ \name age -> do
        putStrLn $ "Name:" ++ name ++ " Age:" ++ show (age :: Int)

main :: IO ()
main = do
    args <- getArgs
    case runOptions options args of
        Left (ParseFailed msg _ _) -> do
            putStrLn msg
            putStrLn $ getHelpDescription options
        Right actions -> sequence_ actions