@@ -47,12 +47,15 @@ noProgressReporting = return $ ProgressReporting
47
47
, inProgress = const id
48
48
, progressStop = pure ()
49
49
}
50
+
51
+ -- | State used in 'delayedProgressReporting'
50
52
data State
51
53
= NotStarted
52
54
| Completed
53
55
| Stopped
54
56
| Running (Async () )
55
57
58
+ -- | State transitions used in 'delayedProgressReporting'
56
59
data Transition = Event ProgressEvent | StopProgress
57
60
58
61
updateState :: IO () -> Transition -> State -> IO State
@@ -65,7 +68,12 @@ updateState _ (Event KickCompleted) st = pure st
65
68
updateState _ StopProgress (Running a) = cancel a $> Stopped
66
69
updateState _ StopProgress st = pure st
67
70
68
- data InProgress = InProgress { todo , done :: ! Int , current :: ! (HMap. HashMap NormalizedFilePath Int )}
71
+ -- | Data structure to track progress across the project
72
+ data InProgress = InProgress
73
+ { todo :: ! Int -- ^ Number of files to do
74
+ , done :: ! Int -- ^ Number of files done
75
+ , current :: ! (HMap. HashMap NormalizedFilePath Int )
76
+ }
69
77
70
78
recordProgress :: NormalizedFilePath -> (Int -> Int ) -> InProgress -> InProgress
71
79
recordProgress file shift InProgress {.. } = case HMap. alterF alter file current of
@@ -79,7 +87,6 @@ recordProgress file shift InProgress{..} = case HMap.alterF alter file current o
79
87
-- | A 'ProgressReporting' that enqueues Begin and End notifications in a new
80
88
-- thread, with a grace period (nothing will be sent if 'KickCompleted' arrives
81
89
-- before the end of the grace period).
82
- -- Avoid using in tests where progress notifications are used to assert invariants.
83
90
delayedProgressReporting
84
91
:: Seconds -- ^ Grace period before starting
85
92
-> Seconds -- ^ sampling delay
0 commit comments