conferer-0.4.1.1: Configuration management library

Safe HaskellSafe
LanguageHaskell2010

Conferer.Core

Synopsis

Documentation

getKey :: Key -> Config -> IO (Maybe Text) Source #

Most Basic function to interact directly with a Config. It always returns Text in the case of success and implements the logic to traverse sources inside the Config.

getFromConfig :: forall a. (Typeable a, FromConfig a, DefaultConfig a) => Key -> Config -> IO a Source #

Fetch a value from a config under some specific key that's parsed using the FromConfig instance, and as a default it uses the value from DefaultConfig.

Notes: - This function may throw an exception if parsing fails for any subkey

getFromRootConfig :: forall a. (Typeable a, FromConfig a, DefaultConfig a) => Config -> IO a Source #

Same as getFromConfig using the root key

Notes: - This function may throw an exception if parsing fails for any subkey

getFromConfigWithDefault :: forall a. (Typeable a, FromConfig a) => Key -> Config -> a -> IO a Source #

Same as getFromConfig but with a user defined default (instead of DefaultConfig instance)

Useful for fetching primitive types

safeGetFromConfig :: forall a. (Typeable a, FromConfig a, DefaultConfig a) => Key -> Config -> IO (Maybe a) Source #

Fetch a value from a config key that's parsed using the FromConfig instance.

Note: This function does not use default so the value must be fully defined by the config only, meaning using this function for many records will always result in Nothing (if the record contains a value that can never be retrieved like a function)

safeGetFromConfigWithDefault :: forall a. (Typeable a, FromConfig a) => Key -> Config -> a -> IO (Maybe a) Source #

Same as safeGetFromConfig but with a user defined default

(/.) :: Key -> Key -> Key Source #

Create a new Key by concatenating two existing keys.

emptyConfig :: Config Source #

The empty configuration, this Config is used as the base for most config creating functions.

addSource :: SourceCreator -> Config -> IO Config Source #

Instantiate a Source using an SourceCretor and a Config and add to the config

unsafeGetKey :: Key -> Config -> IO Text Source #

Same as getKey but it throws if the Key isn't found