@@ -47,12 +47,15 @@ noProgressReporting = return $ ProgressReporting
4747 , inProgress = const id
4848 , progressStop = pure ()
4949 }
50+
51+ -- | State used in 'delayedProgressReporting'
5052data State
5153 = NotStarted
5254 | Completed
5355 | Stopped
5456 | Running (Async () )
5557
58+ -- | State transitions used in 'delayedProgressReporting'
5659data Transition = Event ProgressEvent | StopProgress
5760
5861updateState :: IO () -> Transition -> State -> IO State
@@ -65,7 +68,12 @@ updateState _ (Event KickCompleted) st = pure st
6568updateState _ StopProgress (Running a) = cancel a $> Stopped
6669updateState _ StopProgress st = pure st
6770
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+ }
6977
7078recordProgress :: NormalizedFilePath -> (Int -> Int ) -> InProgress -> InProgress
7179recordProgress 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
7987-- | A 'ProgressReporting' that enqueues Begin and End notifications in a new
8088-- thread, with a grace period (nothing will be sent if 'KickCompleted' arrives
8189-- before the end of the grace period).
82- -- Avoid using in tests where progress notifications are used to assert invariants.
8390delayedProgressReporting
8491 :: Seconds -- ^ Grace period before starting
8592 -> Seconds -- ^ sampling delay
0 commit comments