Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Config = Config [Key] Object
- newtype KeyError = KeyError Key
- type Key = Text
- load :: FilePath -> IO Config
- keys :: Config -> [Key]
- subconfig :: Monad m => Key -> Config -> m Config
- lookup :: (Monad m, FromJSON a) => Key -> Config -> m a
- lookupDefault :: FromJSON a => Key -> a -> Config -> a
- fullpath :: Config -> Key -> Key
Types
Type contains config section and path from root.
This error can be raised if config has not target path.
Loading
load :: FilePath -> IO Config Source
Attempts to load a config from a given YAML file.
Fails with InvalidYaml
if the file does not exist.
>>>
config <- load "example.yaml"
Access functions
keys :: Config -> [Key] Source
Returns all toplevel keys in a config.
>>>
keys config
["section1","section2"]
Narrows into a config section corresponding to a given key.
Fails with a KeyError
if a key doesn't exist at the current level.
>>>
:set -XOverloadedStrings
>>>
sub <- subconfig "section1" config
Returns a value for a given key.
Fails with a KeyError
if the key doesn't exist.
>>>
keys sub
["field1","field2"]>>>
putStrLn =<< lookup "field1" sub
value1