aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2015-10-29 16:40:24 +0100
committerJoris2015-10-29 16:40:24 +0100
commitb886ef9b847b63528a40c41b333937007b8f57c5 (patch)
tree43336baab738afddf5a6009f024553045d28bacc
parentee3027b53aad38178f4945c459a94489f4997507 (diff)
Add currency in conf
-rw-r--r--README.md11
-rw-r--r--config.txt1
-rw-r--r--src/server/Config.hs12
3 files changed, 18 insertions, 6 deletions
diff --git a/README.md b/README.md
index 42a3802..7023624 100644
--- a/README.md
+++ b/README.md
@@ -11,3 +11,14 @@ elm package install
npm install
npm run watch
```
+
+## Configuration
+
+Here is an example configuration file:
+
+```
+hostname = localhost:3001
+port = 3001
+sign-in-expiration-mn = 5
+currency = €
+```
diff --git a/config.txt b/config.txt
index efbd709..1c9e0b0 100644
--- a/config.txt
+++ b/config.txt
@@ -1,3 +1,4 @@
hostname = localhost:3001
port = 3001
sign-in-expiration-mn = 5
+currency = €
diff --git a/src/server/Config.hs b/src/server/Config.hs
index 895b355..deb2e68 100644
--- a/src/server/Config.hs
+++ b/src/server/Config.hs
@@ -14,21 +14,21 @@ import Control.Monad.Trans.Error (runErrorT)
import Control.Monad.IO.Class (liftIO)
import Control.Monad (join)
import Control.Arrow (left)
-import Control.Applicative (liftA3)
data Config = Config
{ hostname :: Text
, port :: Int
, signInExpirationMn :: Int
+ , currency :: Char
} deriving (Read, Eq, Show)
getConfig :: FilePath -> IO (Either Text Config)
getConfig filePath =
left (T.pack . show) <$> (runErrorT $ do
cp <- join $ liftIO $ readfile emptyCP filePath
- liftA3
- Config
- (T.pack <$> get cp "DEFAULT" "hostname")
- (get cp "DEFAULT" "port")
- (get cp "DEFAULT" "sign-in-expiration-mn")
+ Config <$>
+ (T.pack <$> get cp "DEFAULT" "hostname") <*>
+ (get cp "DEFAULT" "port") <*>
+ (get cp "DEFAULT" "sign-in-expiration-mn") <*>
+ (get cp "DEFAULT" "currency")
)