diff options
Diffstat (limited to 'src/Conf.hs')
-rw-r--r-- | src/Conf.hs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/Conf.hs b/src/Conf.hs index fccf2a5..03f8dc2 100644 --- a/src/Conf.hs +++ b/src/Conf.hs @@ -6,27 +6,32 @@ module Conf ) where import Data.Text (Text) +import qualified Data.Text as T import qualified Data.ConfigManager as Conf import Data.Time.Clock (NominalDiffTime) import Model.URL data Conf = Conf - { url :: URL + { urls :: [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 - ) +parse :: FilePath -> IO Conf +parse path = do + conf <- + (flip fmap) (Conf.readConfig path) (\configOrError -> do + conf <- configOrError + Conf <$> + Conf.lookup "urls" conf <*> + Conf.lookup "mailFrom" conf <*> + Conf.lookup "mailTo" conf <*> + Conf.lookup "properties" conf <*> + Conf.lookup "listenInterval" conf + ) + case conf of + Left msg -> error (T.unpack msg) + Right c -> return c |