From 19b56738c6d8b06859aa5c0a5a57d773275abfe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Thu, 1 May 2014 02:10:42 +0200 Subject: [PATCH] Add `withDirectory_` to Utils --- Language/Haskell/GhcMod/Utils.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Language/Haskell/GhcMod/Utils.hs b/Language/Haskell/GhcMod/Utils.hs index 33a327f..09a87a5 100644 --- a/Language/Haskell/GhcMod/Utils.hs +++ b/Language/Haskell/GhcMod/Utils.hs @@ -18,3 +18,8 @@ readProcess' cmd opts = do fail $ cmd ++ " " ++ unwords opts ++ " (exit " ++ show val ++ ")" ExitSuccess -> return output + +withDirectory_ :: FilePath -> IO a -> IO a +withDirectory_ dir action = + bracket getCurrentDirectory setCurrentDirectory + (\_ -> setCurrentDirectory dir >> action)