-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConf.hs
48 lines (39 loc) · 1.44 KB
/
Conf.hs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- "THE BEER-WARE LICENSE" (Revision 42):
-- Albatrouss and <skruppy@onmars.eu> wrote this software. As long as you retain
-- this notice you can do whatever you want with this stuff. If we meet some
-- day, and you think this stuff is worth it, you can buy me a beer in return.
-- -- Albatrouss and Skruppy
module Conf (IntermediateCfg(..),defaultCfg,emptyCfg,mergeCfg) where
import Util
data IntermediateCfg = IntermediateCfg
{ host :: Maybe String
, port :: Maybe String
, conf :: Maybe String
, gameId :: Maybe String
, player :: Maybe Int
} deriving (Eq, Show)
defaultCfg = IntermediateCfg
{ host = Just "sysprak.onmars.eu"
, port = Just "1357"
, conf = Just "client.cfg"
, gameId = Nothing
, player = Nothing
}
-- This definition is so boring, we had to add a joke:
-- Chuck Norris can write Haskell... in assembler.
emptyCfg = IntermediateCfg
{ host = Nothing
, port = Nothing
, conf = Nothing
, gameId = Nothing
, player = Nothing
}
mergeCfg cfgs = foldr merger emptyCfg cfgs
where
merger a b = IntermediateCfg
{ host = mergeMaybe (host a) (host b)
, port = mergeMaybe (port a) (port b)
, conf = mergeMaybe (conf a) (conf b)
, gameId = mergeMaybe (gameId a) (gameId b)
, player = mergeMaybe (player a) (player b)
}