[reactive] "Time travel" with withNextE

David Sankel camior at gmail.com
Fri Nov 21 11:45:55 EST 2008

On Fri, Nov 21, 2008 at 9:23 AM, Robin Green <greenrd at greenrd.org> wrote:
> withNextE seems to allow occurrences' values to depend on occurrences
> which haven't yet occurred.
> Of course, it doesn't actually allow time travel. If the occurrence is
> not yet computed, presumably it will block until it does.
> Still, this is problematic theoretically. It allows "simulations"
> to be constructed which contain reverse causality (if the simulation
> makes all the input occurrences available immediately). Is this a case
> of making the framework a little too powerful?

In the context of an event, we can distinguish between the time of an
occurrence (t), the time when the occurrence's time is computable
(ct), and the time when the occurrence's value is computable (cv).

Running a real-time simulation on an event, we would certainly want it
to be the case that for all occurrences, cv<t+d and ct<t+d for some d
small enough where the user won't notice.

So let me doctor up an example where withNextE might be useful. Lets
say that in tetris, I have the following event:

> -- Occurs whenever a new piece comes on the screen.
> newPiece :: Event Piece

The time when the value of these occurrences is computable (cv) could
be when the game starts, since it is just a random sequence of pieces.
This is one case where withNextE could make sense (but where withNextE
. withTimeE_ probably wouldn't).

Consider an implementation of a preview pane.

> -- Preview of next piece
> preview ::  Behavior Geometry
> preview = fmap toGeo (stepper (firstE newPiece) (withNextE_ newPiece))


David Sankel

More information about the Reactive mailing list