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.
This commit is contained in:
Joey Hess 2011-05-17 03:10:13 -04:00
parent 75a3f5027f
commit c91929f693
16 changed files with 60 additions and 63 deletions

View file

@ -10,7 +10,7 @@ module Remote.Rsync (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
import Control.Monad.State (liftIO, when)
import Control.Monad.State (liftIO)
import System.FilePath
import System.Directory
import System.Posix.Files
@ -168,9 +168,8 @@ withRsyncScratchDir a = do
nuke tmp
return res
where
nuke d = liftIO $ do
e <- doesDirectoryExist d
when e $ liftIO $ removeDirectoryRecursive d
nuke d = liftIO $
doesDirectoryExist d <&> removeDirectoryRecursive d
rsyncRemote :: RsyncOpts -> [CommandParam] -> Annex Bool
rsyncRemote o params = do