My specific problem is like this:
Given an Event t [a]
and an Event t ()
(let's say it's a tick event), I want to produce an Event t a
, that is, an event that is giving me consecutive items from input list for every occurence of tick event.
Reflex has following helper:
zipListWithEvent :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> c) -> [a] -> Event t b -> m (Event t c)
which is doing exactly what I want, but does not take an event as an input, but just a list. Given that I have an Event t [a]
, I thought I could produce an event containing event and just switch, but the problem is that zipListWithEven
operates in monadic context, therefore I can get:
Event t (m (Event t a))
which is something that switch
primitive does not accept.
Now, maybe I'm approaching it in wrong way, so here's my general problem. Given an event that's producing list of coordinates and tick event, I want to produce an event that I can "use" to move an object along the coordinates. So each time tick fires, the position is updated. And each time I update the coordinates list, it begins to produce positions from that new list.