The envparse package

[ Tags: bsd3, library, system ] [ Propose Tags ]

Here's a simple example of a program that uses envparse's parser:

module Main (main) where

import Control.Monad (unless)
import Env

data Hello = Hello { name :: String, quiet :: Bool }

hello :: IO Hello
hello = Env.parse (header "envparse example") $
  Hello <$> var (str <=< nonempty) "NAME"  (help "Target for the greeting")
        <*> switch                 "QUIET" (help "Whether to actually print the greeting")
main :: IO ()
main = do
  Hello {name, quiet} <- hello
  unless quiet $
    putStrLn ("Hello, " ++ name ++ "!")

The NAME environment variable is mandatory and contains the name of the person to greet. QUIET, on the other hand, is an optional boolean flag, false by default, that decides whether the greeting should be silent.

If the NAME variable is undefined in the environment then running the program will result in the following help text:

envparse example
Available environment variables:
  NAME                   Target for the greeting
  QUIET                  Whether to actually print the
Parsing errors:
  NAME is unset

[Skip to Readme]


Versions 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4
Change log CHANGELOG.markdown
Dependencies base (>=4.6 && <5), containers [details]
License BSD3
Copyright 2015 Matvey Aksenov
Author Matvey Aksenov
Category System
Home page
Source repository head: git clone
this: git clone 0.3.3)
Uploaded Mon May 2 12:02:44 UTC 2016 by MatveyAksenov
Distributions LTSHaskell:0.4, NixOS:0.4, Stackage:0.4, Tumbleweed:0.4
Downloads 975 total (36 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-11-26 [all 2 reports]
Hackage Matrix CI


  • Env
    • Env.Generic


Maintainer's Corner

For package maintainers and hackage trustees

Readme for envparse-0.3.3

[back to package description]


Hackage Build Status

optparse-applicative, but for environment variables

See example/Main.hs for an executable example