blob: fccf2a59d774160bf5cba98ab6c2436a152556cd (
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
27
28
29
30
31
32
|
{-# LANGUAGE OverloadedStrings #-}
module Conf
( parse
, Conf(..)
) where
import Data.Text (Text)
import qualified Data.ConfigManager as Conf
import Data.Time.Clock (NominalDiffTime)
import Model.URL
data Conf = Conf
{ url :: URL
, mailFrom :: Text
, mailTo :: [Text]
, properties :: [Text]
, listenInterval :: NominalDiffTime
} deriving Show
parse :: FilePath -> IO (Either Text Conf)
parse path =
(flip fmap) (Conf.readConfig path) (\configOrError -> do
conf <- configOrError
Conf <$>
Conf.lookup "url" conf <*>
Conf.lookup "mailFrom" conf <*>
Conf.lookup "mailTo" conf <*>
Conf.lookup "properties" conf <*>
Conf.lookup "listenInterval" conf
)
|