generic-env-0.1.1.0: Generic Environment Generator

GenericEnv

Synopsis

# Documentation

fromEnv :: forall env. (Generic env, Envable (Rep env)) => EnvOptions -> IO (Either String env) Source #

Tries to produce type env from the environment variables. The Envable restriction is for ensuring type is a record-syntaxed product type.

Constructors

 EnvOptions FieldsmodifyFieldNames :: String -> StringField names of the type can be modified. For a type: data MyEnv { _eName :: String, _eCount :: Int } you may want to eliminate the prefixes beforehand. Then options would be: defaultOptions { modifyFieldNames = drop 2 } envKeyPrefix :: StringPrefix for the environment variable keys. If your type is data MyEnv { name :: String, count :: Int } you might be using environment variables like the following: APP_NAME=genericenv APP_COUNT=3 The prefix should be APP_ in this case.

This function is for generating the most common use case. Only sets the prefix over the default env options.