after is a better name for observe_

This commit is contained in:
Joey Hess 2012-01-03 00:29:27 -04:00
parent 34abd7bca8
commit ee554542c1
3 changed files with 9 additions and 10 deletions

View file

@ -182,7 +182,7 @@ onLocal r a = do
-- No need to update the branch; its data is not used -- No need to update the branch; its data is not used
-- for anything onLocal is used to do. -- for anything onLocal is used to do.
Annex.BranchState.disableUpdate Annex.BranchState.disableUpdate
observe_ (liftIO Git.Command.reap) a liftIO Git.Command.reap `after` a
keyUrls :: Git.Repo -> Key -> [String] keyUrls :: Git.Repo -> Key -> [String]
keyUrls r key = map tourl (annexLocations key) keyUrls r key = map tourl (annexLocations key)
@ -217,9 +217,9 @@ copyToRemote r key
-- run copy from perspective of remote -- run copy from perspective of remote
liftIO $ onLocal r $ do liftIO $ onLocal r $ do
ensureInitialized ensureInitialized
observe_ Annex.Content.saveState $ Annex.Content.saveState `after`
Annex.Content.getViaTmp key $ Annex.Content.getViaTmp key
rsyncOrCopyFile params keysrc (rsyncOrCopyFile params keysrc)
| Git.repoIsSsh r = do | Git.repoIsSsh r = do
keysrc <- inRepo $ gitAnnexLocation key keysrc <- inRepo $ gitAnnexLocation key
rsyncHelper =<< rsyncParamsRemote r False key keysrc rsyncHelper =<< rsyncParamsRemote r False key keysrc

View file

@ -172,7 +172,7 @@ withRsyncScratchDir a = do
let tmp = t </> "rsynctmp" </> show pid let tmp = t </> "rsynctmp" </> show pid
nuke tmp nuke tmp
liftIO $ createDirectoryIfMissing True tmp liftIO $ createDirectoryIfMissing True tmp
observe_ (nuke tmp) (a tmp) nuke tmp `after` a tmp
where where
nuke d = liftIO $ nuke d = liftIO $
doesDirectoryExist d >>? removeDirectoryRecursive d doesDirectoryExist d >>? removeDirectoryRecursive d

View file

@ -29,14 +29,13 @@ anyM p = liftM isJust . firstM p
untilTrue :: (Monad m) => [a] -> (a -> m Bool) -> m Bool untilTrue :: (Monad m) => [a] -> (a -> m Bool) -> m Bool
untilTrue = flip anyM untilTrue = flip anyM
{- Runs a monadic action, passing its value to an observer {- Runs an action, passing its value to an observer before returning it. -}
- before returning it. -}
observe :: (Monad m) => (a -> m b) -> m a -> m a observe :: (Monad m) => (a -> m b) -> m a -> m a
observe observer a = do observe observer a = do
r <- a r <- a
_ <- observer r _ <- observer r
return r return r
{- Like observe, but the observer is not passed the value. -} {- b `after` a runs first a, then b, and returns the value of a -}
observe_ :: (Monad m) => m b -> m a -> m a after :: (Monad m) => m b -> m a -> m a
observe_ observer = observe (const observer) after = observe . const