Last active
December 18, 2015 02:08
-
-
Save funrep/5708584 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Config where | |
import Data.ConfigFile | |
response = "End of /MOTD command." | |
data Config = | |
Config { server :: String, | |
port :: Int, | |
chan :: String, | |
nick :: String, | |
owner :: String } | |
getConfig :: FilePath -> IO Config | |
getConfig f = do | |
xs <- readFile f | |
let conf = do | |
c <- readstring emptyCP xs | |
srv <- get c "DEFAULT" "server" | |
prt <- get c "DEFAULT" "port" | |
chn <- get c "DEFAULT" "chan" | |
nck <- get c "DEFAULT" "nick" | |
own <- get c "DEFAULT" "owner" | |
return Config { server = srv, | |
port = prt, | |
chan = "#" ++ chn, | |
nick = nck, | |
owner = own } | |
case config of | |
Left err -> error $ show err | |
Right conf -> return conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[1 of 1] Compiling Config ( Config.hs, interpreted )
Config.hs:26:5: parse error on input `c'
Failed, modules loaded: none.