Support being built with ghc 8.0.1 (MonadFail)
Tested on an older ghc by enabling MonadFailDesugaring globally. In TransferQueue, the lack of a MonadFail for STM exposed what would normally be a bug in the pattern matching, although in this case an earlier check that the queue was not empty avoided a pattern match failure.
This commit is contained in:
parent
6ec993252e
commit
2e0e557e75
4 changed files with 16 additions and 10 deletions
|
@ -191,16 +191,17 @@ getNextTransfer acceptable = do
|
|||
sz <- readTVar (queuesize q)
|
||||
if sz < 1
|
||||
then retry -- blocks until queuesize changes
|
||||
else do
|
||||
(r@(t,info):rest) <- readTList (queuelist q)
|
||||
void $ modifyTVar' (queuesize q) pred
|
||||
setTList (queuelist q) rest
|
||||
if acceptable info
|
||||
then do
|
||||
adjustTransfersSTM dstatus $
|
||||
M.insert t info
|
||||
return $ Just r
|
||||
else return Nothing
|
||||
else readTList (queuelist q) >>= \case
|
||||
[] -> retry -- blocks until something is queued
|
||||
(r@(t,info):rest) -> do
|
||||
void $ modifyTVar' (queuesize q) pred
|
||||
setTList (queuelist q) rest
|
||||
if acceptable info
|
||||
then do
|
||||
adjustTransfersSTM dstatus $
|
||||
M.insert t info
|
||||
return $ Just r
|
||||
else return Nothing
|
||||
|
||||
{- Moves transfers matching a condition from the queue, to the
|
||||
- currentTransfers map. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue