···
1
-
From 2e0e557e7512ddd0376f179e82c811d8b4cce401 Mon Sep 17 00:00:00 2001
2
-
From: Joey Hess <joeyh@joeyh.name>
3
-
Date: Sat, 5 Jan 2019 11:54:06 -0400
4
-
Subject: [PATCH] Support being built with ghc 8.0.1 (MonadFail)
6
-
Tested on an older ghc by enabling MonadFailDesugaring globally.
8
-
In TransferQueue, the lack of a MonadFail for STM exposed what would
9
-
normally be a bug in the pattern matching, although in this case an
10
-
earlier check that the queue was not empty avoided a pattern match
14
-
Assistant/Monad.hs | 2 ++
15
-
Assistant/TransferQueue.hs | 21 +++++++++++----------
17
-
4 files changed, 16 insertions(+), 10 deletions(-)
19
-
diff --git a/Annex.hs b/Annex.hs
20
-
index 0a0368d36..af0ede1f4 100644
23
-
@@ -74,6 +74,7 @@ import "mtl" Control.Monad.Reader
24
-
import Control.Concurrent
25
-
import Control.Concurrent.Async
26
-
import Control.Concurrent.STM
27
-
+import qualified Control.Monad.Fail as Fail
28
-
import qualified Control.Concurrent.SSem as SSem
29
-
import qualified Data.Map.Strict as M
30
-
import qualified Data.Set as S
31
-
@@ -93,6 +94,7 @@ newtype Annex a = Annex { runAnnex :: ReaderT (MVar AnnexState) IO a }
39
-
diff --git a/Assistant/Monad.hs b/Assistant/Monad.hs
40
-
index 403ee16a8..ef2ee6012 100644
41
-
--- a/Assistant/Monad.hs
42
-
+++ b/Assistant/Monad.hs
43
-
@@ -27,6 +27,7 @@ module Assistant.Monad (
45
-
import "mtl" Control.Monad.Reader
46
-
import System.Log.Logger
47
-
+import qualified Control.Monad.Fail as Fail
50
-
import Assistant.Types.ThreadedMonad
51
-
@@ -49,6 +50,7 @@ newtype Assistant a = Assistant { mkAssistant :: ReaderT AssistantData IO a }
54
-
MonadReader AssistantData,
59
-
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs
60
-
index 6a4473262..7c0ab80d0 100644
61
-
--- a/Assistant/TransferQueue.hs
62
-
+++ b/Assistant/TransferQueue.hs
63
-
@@ -191,17 +191,18 @@ getNextTransfer acceptable = do
64
-
sz <- readTVar (queuesize q)
66
-
then retry -- blocks until queuesize changes
68
-
- (r@(t,info):rest) <- readTList (queuelist q)
69
-
- void $ modifyTVar' (queuesize q) pred
70
-
- setTList (queuelist q) rest
71
-
- if acceptable info
73
-
- adjustTransfersSTM dstatus $
76
-
- else return Nothing
77
-
+ else readTList (queuelist q) >>= \case
78
-
+ [] -> retry -- blocks until something is queued
79
-
+ (r@(t,info):rest) -> do
80
-
+ void $ modifyTVar' (queuesize q) pred
81
-
+ setTList (queuelist q) rest
82
-
+ if acceptable info
84
-
+ adjustTransfersSTM dstatus $
87
-
+ else return Nothing
89
-
{- Moves transfers matching a condition from the queue, to the
90
-
- currentTransfers map. -}