Created
October 17, 2013 14:27
-
-
Save funrep/7025938 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 Tob.Config where | |
import Data.ConfigFile (readstring, emptyCP, get) | |
import Tob.Types | |
getConfig :: FilePath -> IO Config | |
getConfig f = do | |
s <- readFile f | |
let config = do | |
c <- readstring emptyCP s | |
srv <- get c "BOT" "server" | |
prt <- get c "BOT" "port" | |
chn <- get c "BOT" "channel" | |
nck <- get c "BOT" "nick" | |
nme <- get c "BOT" "name" | |
own <- get c "BOT" "owner" | |
return Config { | |
server = srv, | |
port = prt, | |
chan = chn, | |
nick = nck, | |
name = nme, | |
botowner = own } | |
case config of | |
Left err -> error $ show err | |
Right config -> return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
src/Tob/Config.hs:10:5: parse error on input `c'