gitrev-typed
Safe HaskellNone
LanguageHaskell2010

Development.GitRev.Utils.Environment

Description

Provides utilities for querying environment variables.

Since: 0.1

Synopsis

Documentation

newtype LookupEnvError Source #

Environment variable lookup failure. The value is the variable we attempted to look up.

Since: 0.1

Constructors

MkLookupEnvError String 

envValQ Source #

Arguments

:: String

The environment variable k.

-> Q (Either LookupEnvError String)

The result v or an error.

Performs an environment variable lookup in Q.

Examples

Expand
>>> setEnv "SOME_VAR" "val"
>>> $$(qToCode $ envValQ "SOME_VAR")
Right "val"

Since: 0.1

runInEnvDirQ Source #

Arguments

:: String

The environment variable k that should point to some directory d.

-> Q a

The Q action q.

-> Q (Either LookupEnvError a)

The result of running q in directory d.

Runs the given Q-action under the directory d pointed to by the given environment variable.

Examples

Expand
>>> import System.Directory (listDirectory)
>>> setEnv "SOME_DIR" "./src"
>>> $$(qToCode $ runInEnvDirQ "SOME_DIR" $ runIO (listDirectory "./"))
Right ["Development"]

Since: 0.1

withEnvValQ Source #

Arguments

:: String

The environment variable k to lookup.

-> (String -> Q a)

Function to run on k's value if k exists.

-> Q (Either LookupEnvError a) 

Runs a Q-action on the result of an environment variable, if it exists.

Examples

Expand
>>> import System.Directory (listDirectory)
>>> setEnv "SOME_DIR" "./src"
>>> $$(qToCode $ withEnvValQ "SOME_DIR" (runIO . listDirectory))
Right ["Development"]

Since: 0.1