From 1c7d6ea6e3bcd3c672cb5eb3cf22ffc88cabb257 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 20 Mar 2016 22:38:44 +0100 Subject: use config-manager instead of ConfigFile --- src/server/Conf.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/server/Conf.hs (limited to 'src/server/Conf.hs') diff --git a/src/server/Conf.hs b/src/server/Conf.hs new file mode 100644 index 0000000..f66eb5e --- /dev/null +++ b/src/server/Conf.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Conf + ( getConf + , Conf(..) + ) where + +import Data.Text (Text) +import qualified Data.ConfigManager as Conf + +data Conf = Conf + { hostname :: Text + , port :: Int + , signInExpirationMn :: Int + , currency :: Text + } deriving (Read, Eq, Show) + +getConf :: FilePath -> IO (Either Text Conf) +getConf path = + (flip fmap) (Conf.readConfig path) (\configOrError -> do + conf <- configOrError + Conf <$> + Conf.lookup "hostname" conf <*> + Conf.lookup "port" conf <*> + Conf.lookup "signInExpirationMn" conf <*> + Conf.lookup "currency" conf + ) -- cgit v1.2.3