Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Config
- getConfigValue :: (MonadThrow m, FromJSON result) => [Text] -> Config -> m result
- getConfigValueWith :: MonadThrow m => (Value -> Parser a) -> [Text] -> Config -> m a
- getSelectedConfigSource :: MonadThrow m => [Text] -> Config -> m ConfigSource
- getAllConfigSources :: MonadThrow m => [Text] -> Config -> m (Set ConfigSource)
- data ConfigSource
- data ConfigValue
- data ConfigSpec cmd
- data ConfigurationError
- parseConfigSpec :: (MonadCatch m, FromJSON cmd) => Text -> m (ConfigSpec cmd)
- readConfigSpec :: FromJSON cmd => Text -> IO (ConfigSpec cmd)
- resolveDefault :: ConfigSpec cmd -> Config
- resolveFiles :: ConfigSpec cmd -> IO (Config, Vector SomeException)
- resolveEnvPure :: ConfigSpec cmd -> [(Text, Text)] -> Config
- resolveEnv :: ConfigSpec cmd -> IO Config
Config
Use this functions to fetch values from the Etc.Config and cast them to types that make sense in your program
getConfigValue :: (MonadThrow m, FromJSON result) => [Text] -> Config -> m result Source #
getConfigValueWith :: MonadThrow m => (Value -> Parser a) -> [Text] -> Config -> m a Source #
getSelectedConfigSource :: MonadThrow m => [Text] -> Config -> m ConfigSource Source #
getAllConfigSources :: MonadThrow m => [Text] -> Config -> m (Set ConfigSource) Source #
ConfigSpec
Use this functions to read the configuration spec. Remember you can use JSON or YAML(*) filepaths
- The yaml cabal flag must be used to support yaml syntax
data ConfigValue Source #
data ConfigSpec cmd Source #
Eq cmd => Eq (ConfigSpec cmd) Source # | |
Show cmd => Show (ConfigSpec cmd) Source # | |
FromJSON cmd => FromJSON (ConfigSpec cmd) Source # | |
data ConfigurationError Source #
:: (MonadCatch m, FromJSON cmd) | |
=> Text | Text to be parsed |
-> m (ConfigSpec cmd) | returns ConfigSpec |
Parses a text input into a ConfigSpec
, input can be JSON or YAML (if cabal
flag is set).
:: FromJSON cmd | |
=> Text | Filepath where contents are going to be read from and parsed |
-> IO (ConfigSpec cmd) | returns ConfigSpec |
Reads contents of a file and parses into a ConfigSpec
, file contents can be
either JSON or YAML (if cabal flag is set).
Resolvers
Use this functions to gather configuration values from different sources (environment variables, command lines or files). Then compose results together using the mappend function
:: ConfigSpec cmd | ConfigSpec |
-> Config | returns Configuration Map with default values included |
Gathers all default values from the etc/spec
entries inside a ConfigSpec
:: ConfigSpec cmd | Config Spec |
-> IO (Config, Vector SomeException) | Configuration Map with all values from files filled in and a list of warnings |
Gathers configuration values from a list of files specified on the
etc/filepaths
entry of a Config Spec. This will return a Configuration Map
with values from all filepaths merged in, and a list of errors in case there was
an error reading one of the filepaths.
:: ConfigSpec cmd | ConfigSpec |
-> [(Text, Text)] | Environment Variable tuples |
-> Config | returns Configuration Map with Environment Variables values filled in |
Gathers all OS Environment Variable values (env
entries) from the etc/spec
entries inside a ConfigSpec
. This version of the function gathers the input
from a list of tuples rather than the OS.
:: ConfigSpec cmd | Config Spec |
-> IO Config | returns Configuration Map with Environment Variables values filled in |
Gathers all OS Environment Variable values (env
entries) from the etc/spec
entries inside a ConfigSpec
.