From 7f324e08476792e522987867c0f8098eeb0e50e0 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Fri, 9 Nov 2012 02:35:06 +0100 Subject: Use Control.Exception.catch explitly to avoid warnings Ignore-this: 2cebdfe604c581f2b4a644e9aed726c7 The base that comes with ghc-7.6.1 no longer includes Prelude.catch; so these modules were changed so that there is no warning for import Prelude hiding (catch) At the same time these changes should be compatible with older GHCs, since the catch being has never been the one in the Prelude. darcs-hash:20121109013506-1499c-c593662b0780eb49287efcbfe0e9796f7dd57c73.gz --- XMonad/Prompt/DirExec.hs | 5 ++--- XMonad/Prompt/RunOrRaise.hs | 5 ++--- XMonad/Prompt/Shell.hs | 7 +++---- XMonad/Prompt/Ssh.hs | 6 ++---- 4 files changed, 9 insertions(+), 14 deletions(-) (limited to 'XMonad/Prompt') diff --git a/XMonad/Prompt/DirExec.hs b/XMonad/Prompt/DirExec.hs index ddcc8c5..ef37a9a 100644 --- a/XMonad/Prompt/DirExec.hs +++ b/XMonad/Prompt/DirExec.hs @@ -24,8 +24,7 @@ module XMonad.Prompt.DirExec , DirExec ) where -import Prelude hiding (catch) -import Control.Exception +import Control.Exception as E import System.Directory import Control.Monad import Data.List @@ -104,4 +103,4 @@ getDirectoryExecutables path = liftM2 (&&) (doesFileExist x') (liftM executable (getPermissions x')))) - `catch` econst [] + `E.catch` econst [] diff --git a/XMonad/Prompt/RunOrRaise.hs b/XMonad/Prompt/RunOrRaise.hs index 8fb5c43..ce93de9 100644 --- a/XMonad/Prompt/RunOrRaise.hs +++ b/XMonad/Prompt/RunOrRaise.hs @@ -26,8 +26,7 @@ import XMonad.Prompt.Shell import XMonad.Actions.WindowGo (runOrRaise) import XMonad.Util.Run (runProcessWithInput) -import Prelude hiding (catch) -import Control.Exception +import Control.Exception as E import Control.Monad (liftM, liftM2) import System.Directory (doesDirectoryExist, doesFileExist, executable, getPermissions) @@ -71,7 +70,7 @@ isApp "thunderbird" = className =? "Thunderbird-bin" <||> className =? "Thunderb isApp x = liftM2 (==) pid $ pidof x pidof :: String -> Query Int -pidof x = io $ (runProcessWithInput "pidof" [x] [] >>= readIO) `catch` econst 0 +pidof x = io $ (runProcessWithInput "pidof" [x] [] >>= readIO) `E.catch` econst 0 pid :: Query Int pid = ask >>= (\w -> liftX $ withDisplay $ \d -> getPID d w) diff --git a/XMonad/Prompt/Shell.hs b/XMonad/Prompt/Shell.hs index c391ca3..05ee5f4 100644 --- a/XMonad/Prompt/Shell.hs +++ b/XMonad/Prompt/Shell.hs @@ -30,10 +30,9 @@ module XMonad.Prompt.Shell ) where import Codec.Binary.UTF8.String (encodeString) -import Control.Exception +import Control.Exception as E import Control.Monad (forM) import Data.List (isPrefixOf) -import Prelude hiding (catch) import System.Directory (doesDirectoryExist, getDirectoryContents) import System.Environment (getEnv) import System.Posix.Files (getFileStatus, isDirectory) @@ -111,7 +110,7 @@ commandCompletionFunction cmds str | '/' `elem` str = [] getCommands :: IO [String] getCommands = do - p <- getEnv "PATH" `catch` econst [] + p <- getEnv "PATH" `E.catch` econst [] let ds = filter (/= "") $ split ':' p es <- forM ds $ \d -> do exists <- doesDirectoryExist d @@ -142,7 +141,7 @@ isSpecialChar = flip elem " &\\@\"'#?$*()[]{};" -- In order to /set/ an environment variable (eg. combine with a prompt so you can modify @$HTTP_PROXY@ dynamically), -- you need to use 'System.Posix.putEnv'. env :: String -> String -> IO String -env variable fallthrough = getEnv variable `catch` econst fallthrough +env variable fallthrough = getEnv variable `E.catch` econst fallthrough {- | Ask the shell what browser the user likes. If the user hasn't defined any $BROWSER, defaults to returning \"firefox\", since that seems to be the most diff --git a/XMonad/Prompt/Ssh.hs b/XMonad/Prompt/Ssh.hs index c3a035d..e9e7ec8 100644 --- a/XMonad/Prompt/Ssh.hs +++ b/XMonad/Prompt/Ssh.hs @@ -19,15 +19,13 @@ module XMonad.Prompt.Ssh Ssh, ) where -import Prelude hiding (catch) - import XMonad import XMonad.Util.Run import XMonad.Prompt import System.Directory import System.Environment -import Control.Exception +import Control.Exception as E import Control.Monad import Data.Maybe @@ -78,7 +76,7 @@ sshComplListLocal = do sshComplListGlobal :: IO [String] sshComplListGlobal = do - env <- getEnv "SSH_KNOWN_HOSTS" `catch` econst "/nonexistent" + env <- getEnv "SSH_KNOWN_HOSTS" `E.catch` econst "/nonexistent" fs <- mapM fileExists [ env , "/usr/local/etc/ssh/ssh_known_hosts" , "/usr/local/etc/ssh_known_hosts" -- cgit v1.2.3