From c84a2e586563cce90f4324eb38bfb2e2207eb7fc Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 22 Nov 2018 01:10:39 +0000 Subject: Wee refactorings --- src/app/Main.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/app') diff --git a/src/app/Main.hs b/src/app/Main.hs index c96c47e..22834b1 100644 --- a/src/app/Main.hs +++ b/src/app/Main.hs @@ -40,6 +40,7 @@ import System.Posix.Files import Control.Concurrent.Async (Async, cancel) import Control.Exception (bracket) import Control.Monad (unless) +import Control.Monad.IO.Class (liftIO) import Text.Read (readMaybe) import Xmobar.Signal (setupSignalHandler, withDeferSignals) @@ -100,9 +101,9 @@ splitTemplate conf = -- | Reads the configuration files or quits with an error 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 + file <- liftIO $ fileExist f + s <- liftIO $ 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) return $ parseConfig s @@ -123,10 +124,10 @@ getXdgConfigFile = fmap ( "xmobarrc") xmobarConfigDir readDefaultConfig :: IO (Config,[String]) readDefaultConfig = do xdgConfigFile <- getXdgConfigFile - xdgConfigFileExists <- io $ fileExist xdgConfigFile - home <- io $ getEnv "HOME" + xdgConfigFileExists <- liftIO $ fileExist xdgConfigFile + home <- liftIO $ getEnv "HOME" let defaultConfigFile = home ++ "/.xmobarrc" - defaultConfigFileExists <- io $ fileExist defaultConfigFile + defaultConfigFileExists <- liftIO $ fileExist defaultConfigFile if xdgConfigFileExists then readConfig xdgConfigFile else if defaultConfigFileExists -- cgit v1.2.3