aboutsummaryrefslogtreecommitdiff
path: root/Annex/ChangedRefs.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-11-15 16:55:38 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-11-15 16:59:32 -0400
commit4888bd597e34dce996fd581bb417ce017099171b (patch)
tree8b97f6807b5528be6b00c8d21038057ca097ec29 /Annex/ChangedRefs.hs
parent01c524779136a688abf312e721abce41d2dd109c (diff)
enable LambdaCase and convert around 10% of places that could use it
Needs ghc 7.6.1, so minimum base version increased slightly. All builds are well above this version of ghc, and debian oldstable is as well. Code that could use lambdacase can be found by running: git grep -B 1 'case ' | less and searching in less for "<-" This commit was sponsored by andrea rota.
Diffstat (limited to 'Annex/ChangedRefs.hs')
-rw-r--r--Annex/ChangedRefs.hs21
1 files changed, 8 insertions, 13 deletions
diff --git a/Annex/ChangedRefs.hs b/Annex/ChangedRefs.hs
index 1f2372c04..edef1c06c 100644
--- a/Annex/ChangedRefs.hs
+++ b/Annex/ChangedRefs.hs
@@ -39,31 +39,26 @@ data ChangedRefsHandle = ChangedRefsHandle DirWatcherHandle (TBMChan Git.Sha)
-- When possible, coalesce ref writes that occur closely together
-- in time. Delay up to 0.05 seconds to get more ref writes.
waitChangedRefs :: ChangedRefsHandle -> IO ChangedRefs
-waitChangedRefs (ChangedRefsHandle _ chan) = do
- v <- atomically $ readTBMChan chan
- case v of
+waitChangedRefs (ChangedRefsHandle _ chan) =
+ atomically (readTBMChan chan) >>= \case
Nothing -> return $ ChangedRefs []
Just r -> do
threadDelay 50000
rs <- atomically $ loop []
return $ ChangedRefs (r:rs)
where
- loop rs = do
- v <- tryReadTBMChan chan
- case v of
- Just (Just r) -> loop (r:rs)
- _ -> return rs
+ loop rs = tryReadTBMChan chan >>= \case
+ Just (Just r) -> loop (r:rs)
+ _ -> return rs
-- | Remove any changes that might be buffered in the channel,
-- without waiting for any new changes.
drainChangedRefs :: ChangedRefsHandle -> IO ()
drainChangedRefs (ChangedRefsHandle _ chan) = atomically go
where
- go = do
- v <- tryReadTBMChan chan
- case v of
- Just (Just _) -> go
- _ -> return ()
+ go = tryReadTBMChan chan >>= \case
+ Just (Just _) -> go
+ _ -> return ()
stopWatchingChangedRefs :: ChangedRefsHandle -> IO ()
stopWatchingChangedRefs h@(ChangedRefsHandle wh chan) = do