From bf460a0a98d7e4c7f4eac525fcf300629db582b6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Nov 2011 15:34:10 -0400 Subject: reorder repo parameters last Many functions took the repo as their first parameter. Changing it consistently to be the last parameter allows doing some useful things with currying, that reduce boilerplate. In particular, g <- gitRepo is almost never needed now, instead use inRepo to run an IO action in the repo, and fromRepo to get a value from the repo. This also provides more opportunities to use monadic and applicative combinators. --- Command/DropUnused.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Command/DropUnused.hs') diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs index 70dcc4cc7..55c21f83b 100644 --- a/Command/DropUnused.hs +++ b/Command/DropUnused.hs @@ -58,17 +58,15 @@ perform key = maybe droplocal dropremote =<< Annex.getState Annex.fromremote next $ Command.Drop.cleanupRemote key r droplocal = Command.Drop.performLocal key (Just 0) -- force drop -performOther :: (Git.Repo -> Key -> FilePath) -> Key -> CommandPerform +performOther :: (Key -> Git.Repo -> FilePath) -> Key -> CommandPerform performOther filespec key = do - g <- gitRepo - let f = filespec g key + f <- fromRepo $ filespec key liftIO $ whenM (doesFileExist f) $ removeFile f next $ return True readUnusedLog :: FilePath -> Annex UnusedMap readUnusedLog prefix = do - g <- gitRepo - let f = gitAnnexUnusedLog prefix g + f <- fromRepo $ gitAnnexUnusedLog prefix e <- liftIO $ doesFileExist f if e then M.fromList . map parse . lines <$> liftIO (readFile f) -- cgit v1.2.3