I'm using Pipes.Concurrent to write a short GUI program with GTK. It's a minesweeper-esque game, so I'm constructing a grid of buttons.
I construct and connect my buttons with:
b <- buttonNewWithLabel (show $ adjacencies board ! i)
on b buttonActivated
$ void . atomically $ send output (ClickSignal i (mines board ! i))
return b
And I connect the pipe with:
(output, input) <- spawn (latest (ClickSignal 0 False))
let run = do
sig <- await
case sig of
ClickSignal i isMine ->
if isMine
then do
lift $ labelSetText info (show i ++ " -- LOSE!")
else do
lift $ labelSetText info (show i ++ " -- Ok")
run
Empty -> do
lift $ labelSetText info "Empty Case"
run
void . forkIO $ do
runEffect $ fromInput input >-> run
performGC
It runs almost as expected. But if I click on button 1, nothing happens. But if I press button 23, it will update the info label to "1..". If I click on another button, it will update to "23..", and so forth.
I suspect that either I'm failing to understand how concurrent pipes are meant to work on some level or lazy IO is doing something weird.