blob: eb15ddf9eb8598876cddf602be5a18fabaef3c43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module Data.ConfigManager
( readConfig
, lookup
, lookupDefault
) where
import Prelude hiding (lookup)
import Text.Read (readMaybe)
import Control.Monad (join)
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.HashMap.Strict as M
import Data.ConfigManager.Config
import qualified Data.ConfigManager.Reader as R
import Data.ConfigManager.Expr
readConfig :: FilePath -> IO (Either Text Config)
readConfig = R.readConfig
lookup :: Read a => Name -> Config -> Maybe a
lookup name config = join . fmap (readMaybe . T.unpack) $ M.lookup name (hashMap config)
lookupDefault :: Value -> Name -> Config -> Value
lookupDefault defaultValue name config = M.lookupDefault defaultValue name (hashMap config)
|