From 1dbf8fdf450f412f6d7ee688ad248a62d5d992f8 Mon Sep 17 00:00:00 2001 From: malteneuss Date: Wed, 14 Aug 2024 23:01:08 +0200 Subject: [PATCH] Add example on how to build Yaml Value in loadYamlSettings --- yaml/src/Data/Yaml/Config.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yaml/src/Data/Yaml/Config.hs b/yaml/src/Data/Yaml/Config.hs index 743f124..e1c5fd6 100644 --- a/yaml/src/Data/Yaml/Config.hs +++ b/yaml/src/Data/Yaml/Config.hs @@ -5,7 +5,7 @@ -- 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@. +-- A yaml value of @_env:ENV_VAR:default@ or just @_env:ENV_VAR@ will lookup the environment variable @ENV_VAR@. -- -- On a historical note, this code was taken directly from the yesod web framework's configuration module. module Data.Yaml.Config @@ -185,6 +185,11 @@ requireCustomEnv = RequireCustomEnv -- -- > loadYamlSettings ["config/foo.yaml"] [] useEnv -- +-- Alternatively you can configure settings through the Yaml @Value@ directly in Haskell. +-- For example, to load up settings from only from environment variables, you can use: +-- +-- > loadYamlSettings [] [object ["connectionString" .= ("_env:DATABASE_URL" :: String)]] requireEnv +-- -- @since 0.8.16 loadYamlSettings :: FromJSON settings