Data.Yaml.Config

yaml-0.8.16: Support for parsing and rendering YAML documents.

Safe Haskell | None
Language | Haskell98

Data.Yaml.Config

Description

Functionality for using YAML as configuration files

In particular, merging environment variables with yaml values

`loadYamlSettings` is a high-level API for loading YAML and merging environment variables. A yaml value of `_env:ENV_VAR:default` will lookup the environment variable `ENV_VAR`.

On a historical note, this code was taken directly from the yesod web framework's configuration module.

Synopsis

- applyCurrentEnv :: Bool -> Value -> IO Value
- getCurrentEnv :: IO (HashMap Text Text)
- applyEnvValue :: Bool -> HashMap Text Text -> Value -> Value
- loadYamlSettings :: FromJSON settings => [FilePath] -> [Value] -> EnvUsage -> IO settings
- data EnvUsage
- ignoreEnv :: EnvUsage
- useEnv :: EnvUsage
- requireEnv :: EnvUsage
- useCustomEnv :: HashMap Text Text -> EnvUsage
- requireCustomEnv :: HashMap Text Text -> EnvUsage

# Documentation

applyCurrentEnv

Arguments

:: Bool | require an environment variable to be present?
-> Value |
-> IO Value |

getCurrentEnv :: IO (HashMap Text Text)

applyEnvValue

Arguments

:: Bool | require an environment variable to be present?
-> HashMap Text Text |
-> Value |
-> Value |

loadYamlSettings

Arguments

:: FromJSON settings |
=> [FilePath] | run time config files to use, earlier files have precedence
-> [Value] | any other values to use, usually from compile time config. overridden by files
-> EnvUsage |
-> IO settings |

Load the settings from the following three sources:

- Run time config files
- Run time environment variables
- The default compile time config file

data EnvUsage

ignoreEnv :: EnvUsage

useEnv :: EnvUsage

requireEnv :: EnvUsage

useCustomEnv :: HashMap Text Text -> EnvUsage

requireCustomEnv :: HashMap Text Text -> EnvUsage