Hi Sasha,<br><br>Thanks for the report.&nbsp; Would you please add a ticket or two on <a href="http://trac.haskell.org/reactive">http://trac.haskell.org/reactive</a>?&nbsp; (You&#39;ll have to register first.)&nbsp; 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&#39;d be great too.<br><br>Relevant QuickCheck tests are always appreciated as well.<br><br>&nbsp;&nbsp; - Conal<br><br><div class="gmail_quote">
On Mon, Nov 10, 2008 at 6:53 PM, Sasha Rush <span dir="ltr">&lt;<a href="mailto:sasha.rush@gmail.com">sasha.rush@gmail.com</a>&gt;</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 &quot;Introducing Reactive: Events.&quot; But was having<br>
commenting issues. I wanted to make the BellMachines &nbsp;actually work<br>
with on the command line so I tried the following code.<br>
<br>
&gt; runMachine :: BellMachine -&gt; IO ()<br>
&gt; runMachine machine = do<br>
&gt; &nbsp; -- get button press<br>
&gt; &nbsp; clock &lt;- makeClock<br>
&gt; &nbsp; (buttonPressed, buttonPressedSink) &lt;- makeEvent clock<br>
&gt; &nbsp; forkIO $ buttonPresses buttonPressedSink<br>
&gt; &nbsp; adaptE (fmap bell $ machine buttonPressed)<br>
&gt; &nbsp; -- run the machine<br>
&gt; &nbsp; where bell = const $ print &quot;beep!&quot;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; buttonPresses sink = sequence_ $ repeat $ (getChar &gt;&gt; sink ())<br>
<br>
&gt; 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>
&quot;Exception: Future mempty: it&#39;ll never happen, buddy&quot;<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&#39;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>