conferer-1.1.0.0: Configuration management library
Copyright(c) 2019 Lucas David Traverso
LicenseMPL-2.0
MaintainerLucas David Traverso <lucas6246@gmail.com>
Stabilityunstable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Conferer.Config.Internal

Description

Internal module providing Config functionality

Synopsis

Documentation

getKey :: Key -> Config -> IO KeyLookupResult Source #

This function runs lookups on the Config, first in Sources in order and then on the Dynamic based defaults.

type KeyMapping = (Key, Key) Source #

Alias for a mapping from one key to another used for transforming keys

data MappedKey Source #

A key that has been transformed using one or many KeyMappings, so that that process can be reversed.

Constructors

MappedKey 

Instances

Instances details
Eq MappedKey Source # 
Instance details

Defined in Conferer.Config.Internal

Show MappedKey Source # 
Instance details

Defined in Conferer.Config.Internal

listSubkeys :: Key -> Config -> IO [Key] Source #

This function lists all available keys under some key, that could be fetched successfully.

listRawSubkeysInSources :: Key -> [Source] -> IO [Key] Source #

This function lists subkeys in some Sources and combines the results

undoMappings :: MappedKey -> Key Source #

This function reverses the mappings in a MappedKey to retrieve the original key.

Assumes that mappings were really used, otherwise it ignores bad values

untilJust :: [IO (Maybe a)] -> IO (Maybe a) Source #

This utility function run a list of IO actions and returns the first that return a Just, if no one does, returns Nothing

getKeysFromMappings :: [KeyMapping] -> Key -> [MappedKey] Source #

This function tries to apply a list of mappings to a key meaning replace the prefix with the new value from the mapping, if the mapping isn't a prefix that mapping is ignored

This function always terminates even in presence of recursive mappings, since it removes the mapping after it was first used, and that causes that eventually the function will run out of keymappings and terminate.

findAndSplitList :: forall a b. (a -> Maybe b) -> [a] -> [([a], b, [a])] Source #

This utility function splits a list based on a cond function and returns a tuple of previous value, next values and the mapped found value.

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

This function gets a value from Sources but ignores mappings and defaults

getKeyFromDefaults :: Key -> Config -> Maybe [Dynamic] Source #

This function gets values from the defaults

emptyConfig :: Config Source #

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

addKeyMappings :: [KeyMapping] -> Config -> Config Source #

This function adds some key mappings to a Config

addDefaults :: [(Key, Dynamic)] -> Config -> Config Source #

This function adds defaults to a Config

removeDefault :: forall t. Typeable t => Key -> Config -> Config Source #

This function removes a default from a Config, this is the oposite of addDefault, it deletes the first element of matching type in a certain Key.

addDefault :: Typeable a => Key -> a -> Config -> Config Source #

This function adds one default of a custom type to a Config

Note that unlike addDefaults this function does the toDyn so no need to do it on the user's side

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

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

addSources :: [SourceCreator] -> Config -> IO Config Source #

Instantiate several Sources using a SourceCreators and a Config and add them to the config in the order defined by the list