Copyright | (c) 2019 Lucas David Traverso |
---|---|
License | MPL-2.0 |
Maintainer | Lucas David Traverso <lucas6246@gmail.com> |
Stability | unstable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Internal module providing Config functionality
Synopsis
- getKey :: Key -> Config -> IO KeyLookupResult
- type KeyMapping = (Key, Key)
- data MappedKey = MappedKey {
- mappingsChain :: [KeyMapping]
- mappedKey :: Key
- listSubkeys :: Key -> Config -> IO [Key]
- listRawSubkeysInSources :: Key -> [Source] -> IO [Key]
- undoMappings :: MappedKey -> Key
- untilJust :: [IO (Maybe a)] -> IO (Maybe a)
- getKeysFromMappings :: [KeyMapping] -> Key -> [MappedKey]
- findAndSplitList :: forall a b. (a -> Maybe b) -> [a] -> [([a], b, [a])]
- getRawKeyInSources :: Key -> Config -> IO (Maybe (Key, Text))
- getKeyFromDefaults :: Key -> Config -> Maybe [Dynamic]
- emptyConfig :: Config
- addKeyMappings :: [KeyMapping] -> Config -> Config
- addDefaults :: [(Key, Dynamic)] -> Config -> Config
- removeDefault :: forall t. Typeable t => Key -> Config -> Config
- addDefault :: Typeable a => Key -> a -> Config -> Config
- addSource :: SourceCreator -> Config -> IO Config
- addSources :: [SourceCreator] -> Config -> IO Config
Documentation
type KeyMapping = (Key, Key) Source #
Alias for a mapping from one key to another used for transforming keys
A key that has been transformed using one or many KeyMapping
s, so that
that process can be reversed.
MappedKey | |
|
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 Source
s 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
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 Source
s 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
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 Source
s using a SourceCreator
s and a Config
and add
them to the config in the order defined by the list