Package0.6.0System
envparse
Parse environment variables
- Version0.6.0
- CategorySystem
- LicenceBSD-3-Clause
- AuthorMatvey Aksenov
- Maintainermatvey.aksenov@gmail.com
- Homepagesupki.github.io/envparse
- Pinned byhackage envparse 0.6.0
- Sourcehackage.haskell.org/package/envparse-0.6.0
Modules
7 modules- Env41Here's a simple example of a program that uses envparse's parser: module Main (main) where
- Env.Generic4Using the Generic facility, this module can derive Parsers automatically. If you have a simple record: {-# LANGUAGE DeriveGeneric #-}
Internal modules · 5
- Env.Internal.Error4This module contains an extensible error infrastructure. Each kind of errors gets a separate type class which encodes
- Env.Internal.Free6Alt F is the free Alternative functor on F
- Env.Internal.Help11
- Env.Internal.Parser25
- Env.Internal.Val3
Description
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 greeting Parsing errors: NAME is unset
Depends on
2 packages- base-4.20.2.0with GHC
- containers-0.7with GHC
Used by in this set · 0
Nothing in this set depends on it.