From a50fd32c3260376dbf7fc60019ec5a700271572e Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Mon, 19 Nov 2007 04:22:55 +0100 Subject: Refactor recompile darcs-hash:20071119032255-a5988-cf1987eab9261b9d8787ab6d36b6437842cf014e.gz --- XMonad/Core.hs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Core.hs b/XMonad/Core.hs index 4990311..8e89ac1 100644 --- a/XMonad/Core.hs +++ b/XMonad/Core.hs @@ -314,22 +314,21 @@ recompile = liftIO $ do let bin = dir ++ "/" ++ "xmonad" err = bin ++ ".errors" src = bin ++ ".hs" - yes <- doesFileExist src - when yes $ do - srcT <- getModificationTime src - binT <- catch (getModificationTime bin) (const $ return srcT) -- needs recompiling - when (srcT >= binT) $ do - status <- bracket (openFile err WriteMode) hClose $ \h -> do - waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-v0"] (Just dir) - Nothing Nothing Nothing (Just h) - - -- now, if it fails, run xmessage to let the user know: - when (status /= ExitSuccess) $ do - ghcErr <- readFile err - let msg = unlines $ - ["Error detected while loading xmonad configuration file: " ++ src] - ++ lines ghcErr ++ ["","Please check the file for errors."] - doubleFork $ executeFile "xmessage" True [msg] Nothing + srcT <- getModTime src + binT <- getModTime bin + when (srcT > binT) $ do + status <- bracket (openFile err WriteMode) hClose $ \h -> do + waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-v0"] (Just dir) + Nothing Nothing Nothing (Just h) + + -- now, if it fails, run xmessage to let the user know: + when (status /= ExitSuccess) $ do + ghcErr <- readFile err + let msg = unlines $ + ["Error detected while loading xmonad configuration file: " ++ src] + ++ lines ghcErr ++ ["","Please check the file for errors."] + doubleFork $ executeFile "xmessage" True [msg] Nothing + where getModTime f = catch (fmap Just $ getModificationTime f) (const $ return Nothing) -- | Run a side effecting action with the current workspace. Like 'when' but whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () -- cgit v1.2.3