My network looks like this:
ePhysics :: Event t () bPlayerForce :: Behavior t (Double,Double) bPlayerPosition :: Behavior t (Double, Double)
ePhysics starts several times with a timer.
I'm having problems defining bPlayerPosition . I intend that it starts with (0,0) , and when ePhysics is launched, bPlayerPosition will be recalculated using bPlayerForce as a parameter.
The problem is that I need to use accumB / stepper to indicate the initial value, but they only work with events, and I cannot get the strength value from bPlayerForce , since only the behavior can get the value of another behavior (using <*> ) .
An alternative would be to simply use <*> , but I donβt have an initial value, so it becomes a meaningless infinite recursion:
let bPlayerPosition = pure calcPosition <*> bPlayerForce <*> bPlayerPosition
I have 3 questions:
- Is there a way to get value from behavior without
<*> ? For example, when is reactimate ing or displaying an event? the question is that I did not have the opportunity to constantly hang from the very beginning. - Will there be a more functional / frp way to do physics? (in general, and those related to the issue)
- How can I solve the presented problem?
source share