[Haskell-cafe] Netwire woes: creating a wire with mkGen_

Francesco Ariis fa-ml at ariis.it
Sat Dec 31 02:23:01 UTC 2016


On Sat, Dec 31, 2016 at 01:50:28AM +0100, Ertugrul Söylemez wrote:
> This is the problem.  You actually have the 'keyEvent' wire twice in
> there, which means that both are trying to take from the 'MVar', which
> in turn means that in any frame if keyQ gets nothing, it's very unlikely
> that keyA will get something (because it runs pretty much directly after
> keyQ), and whenever keyQ gets something, it will clear the MVar, so keyA
> gets nothing again.  The real solution is not to have keyEvent twice in
> there:
> 
>     proc _ -> do
>         keys <- keyEvent -< ()
>         qKeys <- filterE (== 'q') -< keys
>         aKeys <- filterE (== 'a') -< keys
>         hold -< mergeL qKeys aKeys

Very helpful, it's clear now (pity we have to use arrow interface, I much
preferred applicative).

I'll check `wires` too as suggested. Thanks again
-F


More information about the Haskell-Cafe mailing list