HeinrichApfelmus/reactive-banana — Issue #18: (atomic) event switching on behavour values
Author: gcross
Created: 2011-10-26 10:04:55+00:00
State: open

Hey!

This is related to my previous posting, but the issue is sufficiently different I decided to create a new issue.

Suppose we have the following:

behavior :: Behavior (a -> Either b c)
initial_event :: Event a
left_event :: Event b
right_event :: Event c

In issue #17 I mentioned that there is not a clean way to say that left_event fires when initial_event fires and behavior is Left. However, another problem is that it seems both inefficient and possibly dangerous to define left_event and right_event independently because not only does the system have to execute what is essentially the same check twice, but the value of the behavior might change after executing, say, left_event, which causes right_even to fire *in addition* to left_event when this was not wanted.

I would that this would be a whole lot trickier to implement than the functions I suggested in #17, but it would nonetheless be handy for there to be a function something like

switchOnBehavour :: Behavior (a -> Either b c) -> Event a -> (Event b, Event c)

or alternatively (and presumably equivalently)

switch :: Event (Either a b) -> (Event a, Event b)

The semantics functions would include a promise that one and only one of the events in (Event b, Event c) will be fired in response to an input event.