summaryrefslogtreecommitdiffhomepage
path: root/Main.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2010-02-06 01:39:09 +0100
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2010-02-06 01:39:09 +0100
commit2519e7a2b858b205fe02538dd283d4e2e1ae1054 (patch)
treeea48a5de8ab8ae230c0372f0c511c58056ce3f3f /Main.hs
parent9a94be9a1f071f29e23634864f757151a7ebb03f (diff)
downloadxmobar-2519e7a2b858b205fe02538dd283d4e2e1ae1054.tar.gz
xmobar-2519e7a2b858b205fe02538dd283d4e2e1ae1054.tar.bz2
get rid of action-permutations and use parsec permutation library instead
Ignore-this: 73dbcd588c961bd8bb4dd6d0c931cb3760e2949e code gets shorter and error messages maybe meaningful darcs-hash:20100206003909-d6583-631e1c5e75ad7e7334f865828b398f4d2310af5a.gz
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/Main.hs b/Main.hs
index a94c597..c34af3b 100644
--- a/Main.hs
+++ b/Main.hs
@@ -35,8 +35,7 @@ import System.Console.GetOpt
import System.Exit
import System.Environment
import System.Posix.Files
-
-import Control.Monad.Writer (MonadWriter,MonadIO,unless,runWriterT)
+import Control.Monad (unless)
-- $main
@@ -46,9 +45,9 @@ main = do
d <- openDisplay ""
args <- getArgs
(o,file) <- getOpts args
- (c,defaultings) <- runWriterT $ case file of
- [cfgfile] -> readConfig cfgfile
- _ -> readDefaultConfig
+ (c,defaultings) <- case file of
+ [cfgfile] -> readConfig cfgfile
+ _ -> readDefaultConfig
unless (null defaultings) $ putStrLn $ "Fields missing from config defaulted: "
++ intercalate "," defaultings
@@ -68,19 +67,20 @@ main = do
releaseFont d fs
-- | Reads the configuration files or quits with an error
-readConfig :: (MonadIO m, MonadWriter [String] m) => FilePath -> m Config
+readConfig :: FilePath -> IO (Config,[String])
readConfig f = do
file <- io $ fileExist f
s <- io $ if file then readFileSafe f else error $ f ++ ": file not found!\n" ++ usage
either (\err -> error $ f ++ ": configuration file contains errors at:\n" ++ show err)
- id $ parseConfig s
+ return $ parseConfig s
+
-- | Read default configuration file or load the default config
-readDefaultConfig :: (MonadIO m, MonadWriter [String] m) => m Config
+readDefaultConfig :: IO (Config,[String])
readDefaultConfig = do
home <- io $ getEnv "HOME"
let path = home ++ "/.xmobarrc"
f <- io $ fileExist path
- if f then readConfig path else return defaultConfig
+ if f then readConfig path else return (defaultConfig,[])
data Opts = Help
| Version