Hi Sasha,<br><br>Thanks for the report. Would you please add a ticket or two on <a href="http://trac.haskell.org/reactive">http://trac.haskell.org/reactive</a>? (You'll have to register first.) Anything you can do to simplify the breaking example would help.<br>
<br>And if you or anyone else wants to poke around toward nailing down the underlying, that'd be great too.<br><br>Relevant QuickCheck tests are always appreciated as well.<br><br> - Conal<br><br><div class="gmail_quote">
On Mon, Nov 10, 2008 at 6:53 PM, Sasha Rush <span dir="ltr"><<a href="mailto:sasha.rush@gmail.com">sasha.rush@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Tried putting this on "Introducing Reactive: Events." But was having<br>
commenting issues. I wanted to make the BellMachines actually work<br>
with on the command line so I tried the following code.<br>
<br>
> runMachine :: BellMachine -> IO ()<br>
> runMachine machine = do<br>
> -- get button press<br>
> clock <- makeClock<br>
> (buttonPressed, buttonPressedSink) <- makeEvent clock<br>
> forkIO $ buttonPresses buttonPressedSink<br>
> adaptE (fmap bell $ machine buttonPressed)<br>
> -- run the machine<br>
> where bell = const $ print "beep!"<br>
> buttonPresses sink = sequence_ $ repeat $ (getChar >> sink ())<br>
<br>
> main = runMachine metronome<br>
<br>
This guy works fine for the basic machines but it breaks for<br>
metronome. The first reason seems to be that when it gets to a point<br>
when there are no future events, switchE fails.<br>
<br>
"Exception: Future mempty: it'll never happen, buddy"<br>
<br>
I could hack around this, but then I got to another issue. It seems<br>
like switchE is too lazy, which causes my events always fire one click<br>
behind when I press the button. My guess is that since switchE is<br>
implemented with withRestE, it needs to peak ahead one event.<br>
<br>
Not sure how to deal with these issues in practice. Curious if I'm<br>
just doing something wrong.<br>
<br>
Thanks,<br>
Sasha<br>
_______________________________________________<br>
Reactive mailing list<br>
<a href="mailto:Reactive@haskell.org">Reactive@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/reactive" target="_blank">http://www.haskell.org/mailman/listinfo/reactive</a><br>
</blockquote></div><br>