From c91929f6934fc4e94603d0fa004e824d5e2cfb65 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 17 May 2011 03:10:13 -0400 Subject: add whenM and unlessM Just more golfing.. I am pretty sure something in a library somewhere can do this, but I have been unable to find it. --- CopyFile.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'CopyFile.hs') diff --git a/CopyFile.hs b/CopyFile.hs index 4575fb08a..b08ede3c8 100644 --- a/CopyFile.hs +++ b/CopyFile.hs @@ -7,7 +7,6 @@ module CopyFile (copyFile) where -import Control.Monad (when) import System.Directory (doesFileExist, removeFile) import Utility @@ -17,8 +16,7 @@ import qualified SysConfig - and because this allows easy access to features like cp --reflink. -} copyFile :: FilePath -> FilePath -> IO Bool copyFile src dest = do - e <- doesFileExist dest - when e $ + whenM (doesFileExist dest) $ removeFile dest boolSystem "cp" [params, File src, File dest] where -- cgit v1.2.3