Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 37 lines (33 sloc) 1.035 kb
ebc97e8 @Xorlev Switched to config file with help from chrisdone/hulk
authored
1 module Config
2 (Config(..)
3 ,getConfig)
4 where
5
6 import Data.Word
7 import Data.ConfigFile
8 import Network (PortNumber)
9
10 {- let cp = forceEither val
11 server = forceEither $ get cp "" "server"
12 let port = fromIntegral $ forceEither $ get cp "" "port"-}
13
14 data Config = Config {
15 configServer :: String
16 , configPort :: PortNumber
17 , configChannel :: String
18 , configNick :: String
19 } deriving (Show)
20
21 getConfig :: FilePath -> IO Config
22 getConfig conf = do
23 contents <- readFile conf
24 let config = do
25 c <- readstring emptyCP contents
26 server <- get c "" "server"
27 port <- get c "" "port"
28 channel <- get c "" "channel"
29 nick <- get c "" "nick"
30 return Config { configServer = server
31 , configPort = fromIntegral (port::Word16)
32 , configChannel = channel
33 , configNick = nick
34 }
35 case config of
36 Left cperr -> error $ show cperr
37 Right config -> return config
Something went wrong with that request. Please try again.