Also, a less forgetful version of subs might be useful:<br><br>&nbsp;&nbsp;&nbsp;&nbsp; withSubs xs e :: [a] -&gt; Event b -&gt; Event (b,a)<br><br>and then<br><br>&nbsp;&nbsp;&nbsp; subs xs e&nbsp; = snd &lt;$&gt; withSubs xs e<br><br>or, if you like,<br><br>&nbsp;&nbsp;&nbsp; subs = (fmap.fmap.fmap) snd withSubs<br>
<br>Btw, you can read the three fmaps directly from the signature of withSubs (two arrows plus one Event on the way to the pair).<br><br>&nbsp; - Conal<br><br><div class="gmail_quote">On Tue, Nov 18, 2008 at 10:11 AM, Conal Elliott <span dir="ltr">&lt;<a href="mailto:conal@conal.net">conal@conal.net</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;">Cool!&nbsp; Thanks to quicksilver for the insight on and elegant definition of subs.<br><br>How about one of the following terser variations on the randomEvent def:<br>
<br><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; randomEvent std e = subs (randoms g) e</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; randomEvent std = subs (randoms g)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; randomEvent = subs . randoms</span><br><br><br>&nbsp; - Conal<br><br><div class="gmail_quote">2008/11/18 Creighton Hogg <span dir="ltr">&lt;<a href="mailto:wchogg@gmail.com" target="_blank">wchogg@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><div class="gmail_quote"><div><br>Being a dirty schlub &amp; replying to myself, it turns out there is a way to substitute an infinite list into an Event as we&#39;ve talked about this on #haskell this morning.<br>


<br>subs xs e :: [a] -&gt; Event b -&gt; Event a<br>subs xs e = head &lt;$&gt; accumE xs (tail &lt;$ e)<br><br>so then we can very easily do<br><br>randomEvent :: (RandomGen g,Random b) =&gt; g -&gt; Event a -&gt; Event b<br>


randomEvent std e = let vals = randoms g in subs vals e<br><br>Cool!<br>Now I just need to change my Tetris to do that instead of messing with a Behavior.<br><br>&nbsp;<br></div></div><br>
<br></div><div class="Ih2E3d">_______________________________________________<br>
Reactive mailing list<br>
<a href="mailto:Reactive@haskell.org" target="_blank">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>
<br></div></blockquote></div><br>
</blockquote></div><br>