gdritter repos config-ini / c5708f7
Updates to the README Getty Ritter 8 years ago
1 changed file(s) with 9 addition(s) and 7 deletion(s). Collapse all Expand all
2222
2323 ~~~.haskell
2424 data Config = Config
25 { cfNetwork :: NetworkConfig, cfLocal :: Maybe LocalConfig }
26 deriving (Eq, Show)
25 { cfNetwork :: NetworkConfig
26 , cfLocal :: Maybe LocalConfig
27 } deriving (Eq, Show)
2728
2829 data NetworkConfig = NetworkConfig
29 { netHost :: String, netPort :: Int }
30 deriving (Eq, Show)
30 { netHost :: String
31 , netPort :: Int
32 } deriving (Eq, Show)
3133
3234 data LocalConfig = LocalConfig
33 { localUser :: Text }
34 deriving (Eq, Show)
35 { localUser :: Text
36 } deriving (Eq, Show)
3537
3638 configParser :: IniParser Config
3739 configParser = do
4042 port <- fieldOf "port" number
4143 return NetworkConfig { netHost = host, netPort = port }
4244 locCf <- sectionMb "LOCAL" $
43 LocalConfig <$field "user"
45 LocalConfig <$> field "user"
4446 return Config { cfNetwork = netCf, cfLocal = locCf }
4547 ~~~
4648