etc-0.2.0.0: Declarative configuration spec for Haskell projects

Safe HaskellNone
LanguageHaskell2010

System.Etc.Internal.Types

Documentation

newtype Config Source #

Constructors

Config 

filterMaybe :: (a -> Bool) -> Maybe a -> Maybe a Source #

class IConfig config where Source #

Methods

getConfigValue :: (MonadThrow m, FromJSON result) => [Text] -> config -> m result Source #

Fetches a configuration value from a given key, if key is not found, you may pick the failure mode via the MonadThrow interface.

example:

>>> getConfigValue ["db", "user"] config :: Maybe Text
Just "root"
>>> getConfigValue ["db", "password"] config :: Maybe Text
Nothing

getConfigValueWith :: MonadThrow m => (Value -> Parser result) -> [Text] -> config -> m result Source #

Fetches a configuration value from a given key, normally this key will point to a sub-config JSON object, which is then passed to the given JSON parser function. If key is not found, you may pick the failure mode via the MonadThrow interface.

example:

>>> import qualified Data.Aeson as JSON
>>> import qualified Data.Aeson.Types as JSON (Parser)
>>> connectInfoParser :: JSON.Value -> JSON.Parser DbConnectInfo
>>> getConfigValueWith connectInfoParser ["db"] config
Just (DbConnectInfo {...})

getAllConfigSources :: MonadThrow m => [Text] -> config -> m (Set ConfigSource) Source #

getSelectedConfigSource :: MonadThrow m => [Text] -> config -> m ConfigSource Source #