Hi Mike, cafe,
The implementation in the library is essentially the same as in the paper, but B (E [a]) instead of B (E a) allows multiple simultaneous events, whereas the implementation in the paper does not. The result is B (E [a]), where the list is the list of all results in the event stream which occur at that point. Like the implementation in the paper, the behavior switches as soon as the next event occurs.
I'm a bit unclear on your question, neither implementation is recursive. If you want to use event streams it's best not to look at their implementation, which is tricky, but just use the combinators that are available.
You can create a behavior that always give the integration of the values in the eventstream as follows:
integrate :: EvStream (Double,Double) -> Double -> Behavior (Behavior Double)
integrate stream startTime = foldEs update (0,startTime) stream where
update (total, prevTime) (cur, curTime) = let diff = curTime - prevTime * cur
in (total + diff, curTime)
Or use Control.FRPNow.Time.integrate :)
The result will give a Behavior (Behavior Double), because the result depends on when we start integrating to prevent the space leak. Does that answer your question?
Cheers,
Atze