
Hi Peter, Thanks for asking about this issue. If I understood it correctly, it Conal's aim to provide just a single
integral function that can handle both the recursive and regular cases?
But, is this even possible?
Yes. The semantics of reactivity, plus the laziness of Haskell and some
careful programming, makes it possible. I did it long ago in Fran.
Currently the implementation of snapshot (which integral uses) is not lazy
enough for recursive snapshots to work. Chuan-kai Lin came up with a
solution, which I think created a space leak. Richard Smith came up with
essentially the same solution (and leak), and has been continuing to pursue
a sufficiently lazy and space-tight. Today, Richard attached his patch to
ticket # 14 on the Reactive tracker (
http://trac.haskell.org/reactive/ticket/14). I'll check it out and
integrate it if I think it will improve things.
In case anyone's curious, the crucial semantic decision is to have reactive
behaviors change immediately after an event occurs. (Really immediately --
not some finite positive delay.) Thus an event can take a snapshot of a
behavior at the moment that the behavior is reacting to that very event.
The behavior and event are defined in terms of each other, in a well-defined
and useful way.
- Conal
2008/12/2 Peter Verswyvelen
This has been brought up before, but I'm not sure about the current status our consensus regarding "recursive feedback" in Reactive. In Yampa this is solved by the ArrowLoop instance, and by having two different integral functions: one with a delay and without a delay.
If I understood it correctly, it Conal's aim to provide just a single integral function that can handle both the recursive and regular cases?
But, is this even possible?
A nice example of this is David's "boingee" example: a ball on the screen gets dragged towards the current mouse position.
Mathematically, this is
vb(t) = s * ( pm(t) - pb(t) ) pb(t) = pb0 + integral [0..t] vb(t)
where pb(t) is the position of the ball at time t pb0 is the initial position of the ball at time t=0, pm(t) is the position of the mouse at time t s is some arbitrary scale factor
Of course this is not really realistic but it is a simple example of recursive feedback: pb(t) depends on vb(t) and vice versa.
Can we make such behaviors with Reactive?
_______________________________________________ Reactive mailing list Reactive@haskell.org http://www.haskell.org/mailman/listinfo/reactive