[reactive] First draft of reactive-tetris

Conal Elliott conal at conal.net
Tue Nov 18 13:15:27 EST 2008


Also, a less forgetful version of subs might be useful:

     withSubs xs e :: [a] -> Event b -> Event (b,a)

and then

    subs xs e  = snd <$> withSubs xs e

or, if you like,

    subs = (fmap.fmap.fmap) snd withSubs

Btw, you can read the three fmaps directly from the signature of withSubs
(two arrows plus one Event on the way to the pair).

  - Conal

On Tue, Nov 18, 2008 at 10:11 AM, Conal Elliott <conal at conal.net> wrote:

> Cool!  Thanks to quicksilver for the insight on and elegant definition of
> subs.
>
> How about one of the following terser variations on the randomEvent def:
>
>     randomEvent std e = subs (randoms g) e
>
>     randomEvent std = subs (randoms g)
>
>     randomEvent = subs . randoms
>
>
>   - Conal
>
> 2008/11/18 Creighton Hogg <wchogg at gmail.com>
>
>>
>> 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.
>>
>> subs xs e :: [a] -> Event b -> Event a
>> subs xs e = head <$> accumE xs (tail <$ e)
>>
>> so then we can very easily do
>>
>> randomEvent :: (RandomGen g,Random b) => g -> Event a -> Event b
>> randomEvent std e = let vals = randoms g in subs vals e
>>
>> Cool!
>> Now I just need to change my Tetris to do that instead of messing with a
>> Behavior.
>>
>>
>>
>>
>> _______________________________________________
>> Reactive mailing list
>> Reactive at haskell.org
>> http://www.haskell.org/mailman/listinfo/reactive
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/reactive/attachments/20081118/d1b35381/attachment.htm


More information about the Reactive mailing list