Skip to content

Instantly share code, notes, and snippets.

@funrep
Last active December 18, 2015 02:08
Show Gist options
  • Save funrep/5708584 to your computer and use it in GitHub Desktop.
Save funrep/5708584 to your computer and use it in GitHub Desktop.
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
@funrep
Copy link
Author

funrep commented Jun 4, 2013

[1 of 1] Compiling Config ( Config.hs, interpreted )

Config.hs:26:5: parse error on input `c'
Failed, modules loaded: none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment