Also, a less forgetful version of subs might be useful:<br><br> withSubs xs e :: [a] -> Event b -> Event (b,a)<br><br>and then<br><br> subs xs e = snd <$> withSubs xs e<br><br>or, if you like,<br><br> 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> - Conal<br><br><div class="gmail_quote">On Tue, Nov 18, 2008 at 10:11 AM, Conal Elliott <span dir="ltr"><<a href="mailto:conal@conal.net">conal@conal.net</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;">Cool! 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;"> 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;"> 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;"> randomEvent = subs . randoms</span><br><br><br> - Conal<br><br><div class="gmail_quote">2008/11/18 Creighton Hogg <span dir="ltr"><<a href="mailto:wchogg@gmail.com" target="_blank">wchogg@gmail.com</a>></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 & replying to myself, it turns out there is a way to substitute an infinite list into an Event as we've talked about this on #haskell this morning.<br>
<br>subs xs e :: [a] -> Event b -> Event a<br>subs xs e = head <$> accumE xs (tail <$ e)<br><br>so then we can very easily do<br><br>randomEvent :: (RandomGen g,Random b) => g -> Event a -> 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> <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>