diff options
author | Joris | 2016-03-26 20:46:18 +0100 |
---|---|---|
committer | Joris | 2016-03-26 20:46:18 +0100 |
commit | 49639d9796c36b8601beff86c6aa1b1d232ac652 (patch) | |
tree | 04bf8e728d14ee759ad1274381073444747dc9f5 /Data | |
parent | 09befe1f8026a9b3c4c4295e533e481284000802 (diff) |
Document durations
Diffstat (limited to 'Data')
-rw-r--r-- | Data/ConfigManager.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Data/ConfigManager.hs b/Data/ConfigManager.hs index a13457c..02c3469 100644 --- a/Data/ConfigManager.hs +++ b/Data/ConfigManager.hs @@ -83,8 +83,11 @@ lookupDefault defaultValue name config = foldl (flip const) defaultValue $ looku -- > a_double = 4.0 -- > thatIsABoolean = True -- > a_double = 5.0 +-- > diffTime = 1 day +-- > otherDiffTime = 3 hours -- -- If two or more bindings have the same name, only the last one is kept. +-- Accepted duration values are seconds, minutes, hours, days and weeks. -- $import -- @@ -107,15 +110,18 @@ lookupDefault defaultValue name config = foldl (flip const) defaultValue $ looku -- > port = 3000 -- > mailFrom = "no-reply@mail.com" -- > currency = "$" +-- > expiration = 30 minutes -- -- Read the configuration: -- -- > import qualified Data.ConfigManager as Conf +-- > import Data.Time.Clock (DiffTime) -- > -- > data Conf = Conf -- > { port :: Int -- > , mailFrom :: String -- > , currency :: String +-- > , expiration :: DiffTime -- > } deriving (Read, Eq, Show) -- > -- > getConfig :: IO (Either Text Conf) @@ -125,5 +131,6 @@ lookupDefault defaultValue name config = foldl (flip const) defaultValue $ looku -- > Conf <$> -- > Conf.lookup "port" conf <*> -- > Conf.lookup "mailFrom" conf <*> --- > Conf.lookup "currency" conf +-- > Conf.lookup "currency" conf <*> +-- > Conf.lookup "expiration" conf -- > ) |