Generalize the gloss interop layer for Yampa and netwire
gelisam opened this issue · 10 comments
Most of the GlossInterface.hs
implementations are generic, in the sense that they expose all the gloss events and would be useful for any app based on gloss and the chosen FRP library. The implementations for Yampa and netwire, on the contrary, are specific to our toy app because they hardcode renderButtons
, and I'm not sure if they expose the Float events.
If it's not too much work, I think it would be nice if those two implementations could also be made generic. When learning reactive-banana, I found gloss-banana quite useful, and it would be nice if similar wrappers existed for all the other FRP libraries.
I think there's two solutions.
The first one is explicitly sending an initial event and expect to be yielded a Picture
value.
The second one is simply accepts a Picture
value as an argument of play***.
I think the later is suitable, because the possibility to be yielded no Picture
value cannot be eliminated.
Is there any problem to add play*** a Picture
argument?
Sure, whatever works. Another possibility: since gloss requests pictures separately from its event notifications, perhaps there could be three kinds of events: Float, Input, and Render.
For netwire, I found a more sophisticated way: to synchronize the netwire's time with the Gloss's one.
The implementation is 4a66692.
Now time tick events are handled using builtin time functions.
I think it's also possible in Yampa. I'm trying now.
netwire and Yampa have a built-in notion of time? This sounds like an important feature, there should be a label to identify the libraries which have this. Do you think the "continuous" label applies, or do we need a new one?
I think the "continuous" label applies, at least for these two libraries.
Closed.
Great!
I noticed that your netwire commit both removes the dependency on the Buttons module and converts gloss tick events into netwire elapsed time, while the Yampa commit only converts the gloss ticks into Yampa elapsed time. Is there no way to take the NoEvent solution you have used in netwire to obtain the first Picture and to adapt it to Yampa? Perhaps via a dummy EventResize event?
Or, even simpler, we could begin with an empty picture.
Sorry, I just forgot to remove it.
vPic
is updated by react
call at line:31. So the initial value of it is now only a dummy value.
Thanks!