ghc-envparse
Parse environment variables


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&#x7b; name :: String, quiet :: Bool&#x7d; hello :: IO Hello hello = Env.parse (header "envparse example") $&#x20; Hello<$>var (str<=<nonempty) "NAME" (help "Target for the greeting")&#x20;<*>switch "QUIET" (help "Whether to actually print the greeting")&#x20; main :: IO () main = do&#x20; Hello&#x7b;name, quiet&#x7d;<- hello&#x20; unless quiet $&#x20; 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&#x20; Available environment variables:&#x20;&#x20; NAME Target for the greeting&#x20; QUIET Whether to actually print the&#x20; greeting&#x20; Parsing errors:&#x20;&#x20; NAME is unset '.

BSD-3-Clause

cloud_download Downloads

Please select a product to see the available package versions:
Loading...
Loading package downloads...