From 6e9f06455b04e2110bb14eb2c84689cef62ed856 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 14 Nov 2025 13:38:28 -0500 Subject: Thread LineManager through build functions - Reserve line for each concurrent build - Release line on completion with success/failed state - Fix hlint eta reduce warning Task: t-1a1E3j1 --- Omni/Log/Concurrent.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Omni/Log') diff --git a/Omni/Log/Concurrent.hs b/Omni/Log/Concurrent.hs index 2a46df5..5187367 100644 --- a/Omni/Log/Concurrent.hs +++ b/Omni/Log/Concurrent.hs @@ -88,13 +88,13 @@ reserveLine LineManager {..} ns = if not lmSupportsANSI then pure Nothing else - atomicModifyIORef' lmLines <| \lines -> - case findFirstFree lines of - Nothing -> (lines, Nothing) + atomicModifyIORef' lmLines <| \linesMap -> + case findFirstFree linesMap of + Nothing -> (linesMap, Nothing) Just lineNum -> let status = BuildStatus ns "" Building - lines' = Map.insert lineNum (Just status) lines - in (lines', Just lineNum) + linesMap' = Map.insert lineNum (Just status) linesMap + in (linesMap', Just lineNum) where findFirstFree :: Map Int (Maybe BuildStatus) -> Maybe Int findFirstFree m = @@ -127,16 +127,16 @@ updateLine LineManager {..} mLineNum ns output = ANSI.hRestoreCursor IO.stderr - modifyIORef' lmLines <| \lines -> - Map.adjust (fmap (\bs -> bs {bsLastOutput = output})) lineNum lines + modifyIORef' lmLines <| \linesMap -> + Map.adjust (fmap (\bs -> bs {bsLastOutput = output})) lineNum linesMap releaseLine :: LineManager -> Maybe Int -> BuildState -> IO () -releaseLine LineManager {..} mLineNum state = +releaseLine LineManager {..} mLineNum buildState = case mLineNum of Nothing -> pure () Just lineNum -> do - modifyIORef' lmLines <| \lines -> - Map.insert lineNum Nothing lines + modifyIORef' lmLines <| \linesMap -> + Map.insert lineNum Nothing linesMap when lmSupportsANSI <| do current <- readIORef lmCurrentLine @@ -145,7 +145,7 @@ releaseLine LineManager {..} mLineNum state = ANSI.hCursorUp IO.stderr (current - lineNum) ANSI.hClearLine IO.stderr - let statusChar = case state of + let statusChar = case buildState of Success -> "✓" Failed -> "✗" Building -> "…" -- cgit v1.2.3