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

@ -7,13 +7,13 @@
module Command.RecvKey where
import Control.Monad (when)
import Control.Monad.State (liftIO)
import System.Exit
import Command
import CmdLine
import Content
import Utility
import RsyncFile
command :: [Command]
@ -25,9 +25,7 @@ seek = [withKeys start]
start :: CommandStartKey
start key = do
present <- inAnnex key
when present $
error "key is already present in annex"
whenM (inAnnex key) $ error "key is already present in annex"
ok <- getViaTmp key (liftIO . rsyncServerReceive)
if ok