I am implementing the FRP framework in Scala and I seem to have run into a problem. Motivated by some thinking, I decided to limit this question to the public interface of my structure, so Behaviors could be evaluated only in the "present", namely:
behaviour.at(now)
This is also consistent with Conal’s assumption in Franz's work that behavior is always evaluated / selected with increasing time. It restricts conversions to Behaviors, but otherwise we find ourselves in huge problems with Behaviors, which represent some input:
val slider = Stepper(0, sliderChangeEvent)
Using this behavior, an estimate of future values will be incorrect, and an unlimited amount of memory will be required to evaluate past values (all occurrences used in the "slider" event must be saved).
I am having problems specifying the “snapshot” operation in Behaviors, given this limitation. My problem is best explained by an example (using the slider mentioned above):
val event = mouseB
My problem is that if the "mouseB" event occurred when this code is executed, the current "stepper" value will be the last "slider" pattern (the value at the time it last appeared). If the time of the last occurrence is in the past, we therefore complete the “slider” estimate using the elapsed time, which violates the above rule (and your original assumption). I see a couple of ways to solve this problem:
- We record the past (save all past events in the event), allowing us to evaluate behavior with past times (using an unlimited amount of memory).
- We modify the “snapshot” to accept a temporary argument (“sample after this time”) and apply this time> = now
- In a more wacky move, we could somehow limit the creation of FRP objects to the initial setup of the program and only start processing events / input after this installation is complete.
I also just could not implement the “pattern” or remove the “stepper” / “switcher” (but I really don't want to do any of these things). Anyone have any thoughts on this? I didn’t understand something?
source share