From cefdff1aa04cb65f65966791a15a2826ad430812 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Fri, 2 Aug 2024 18:14:06 +0300 Subject: [PATCH] wip, okay --- .../lib/Data/Config/Suckless/Script/File.hs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs b/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs index 2f255085..25eb7e6d 100644 --- a/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs +++ b/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs @@ -33,13 +33,22 @@ glob pat ignore dir action = do q <- newTQueueIO - w <- liftIO (async $ go q dir >> atomically (writeTQueue q Nothing)) + void $ liftIO (async $ go q dir >> atomically (writeTQueue q Nothing)) - fix $ \next -> do - e <- atomically (readTQueue q) - case e of - Nothing -> pure () - Just x -> void (action x) >> next + flip runContT pure do + callCC \exit -> do + fix $ \next -> do + e <- atomically do + void (peekTQueue q) + STM.flushTQueue q + + for_ e $ \case + Nothing -> exit () + Just x -> do + r <- lift (action x) + unless r (exit ()) + + next where