
Just to be curious, what would be the definition of withSubs? Something like
withSubs :: [a] -> Event b -> Event (b,a)
withSubs xs = (fmap.fmap) head . stateE xs tail
Haven't tested it, still actively learning reactive...
2008/11/18 Conal Elliott
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
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
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@haskell.org http://www.haskell.org/mailman/listinfo/reactive
_______________________________________________ Reactive mailing list Reactive@haskell.org http://www.haskell.org/mailman/listinfo/reactive