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.
This commit is contained in:
parent
5e6c3ba30c
commit
187b3e7780
13 changed files with 119 additions and 166 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue