aboutsummaryrefslogtreecommitdiff
path: root/Data/ConfigManager.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Data/ConfigManager.hs')
-rw-r--r--Data/ConfigManager.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Data/ConfigManager.hs b/Data/ConfigManager.hs
index aa92554..37da8b6 100644
--- a/Data/ConfigManager.hs
+++ b/Data/ConfigManager.hs
@@ -22,6 +22,9 @@ module Data.ConfigManager
-- ** Comments
-- $comments
+ -- ** Example
+ -- $example
+
-- * Configuration loading
readConfig
@@ -96,3 +99,31 @@ lookupDefault defaultValue name config = foldl (flip const) defaultValue $ looku
--
-- > # Comment
-- > x = 8 # Another comment
+
+-- $example
+--
+-- From application.conf:
+--
+-- > port = 3000
+-- > mailFrom = "no-reply@mail.com"
+-- > currency = "$"
+--
+-- Read the configuration:
+--
+-- > import qualified Data.ConfigManager as Conf
+-- >
+-- > data Conf = Conf
+-- > { port :: Int
+-- > , mailFrom :: String
+-- > , currency :: String
+-- > } deriving (Read, Eq, Show)
+-- >
+-- > getConfig :: IO (Either Text Conf)
+-- > getConfig =
+-- > (flip fmap) (Conf.readConfig "application.conf") (\configOrError -> do
+-- > conf <- configOrError
+-- > Conf <$>
+-- > Conf.lookup "port" conf <*>
+-- > Conf.lookup "mailFrom" conf <*>
+-- > Conf.lookup "currency" conf
+-- > )