Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: a version of reactimate and fromAddHandler that are bidirectional #202

Open
ChristopherKing42 opened this issue Sep 11, 2019 · 1 comment

Comments

@ChristopherKing42
Copy link

ChristopherKing42 commented Sep 11, 2019

The type of the bidirectional reactimate would be Event (IO a) -> MomentIO (Event a). Whenever the input event occurs, the output event is fired. Unlike execute this would not be subject to garbage collection, and unlike mapEventIO the input and output events would be simultaneous. The reason it is called bidirectional is that not only does the event tell the IO action when to be preformed, but also allows the IO action to send a value back to the event network. There would also be a version of the type Event (Future (IO a)) -> MomentIO (Event (Future a)).

The type of bidirectional fromAddHandler would be (a -> Moment (b, c)) -> MomentIO (Event b, a -> IO c). When the IO action is preformed, its argument is used to observe the moment, which then produces the IO action's return value and fires the event. The observing of the moment and the firing of the event are simultaneous. The reason it is called bidirectional is that not only can the IO action tell the event when to fire, but also allows the event network to send a value back to the IO monad. A function of the type Behavior (a -> b) -> MomentIO (a -> IO b) that allows IO to use functions in behaviors could be derived from this, for example. There would also be a version of the type (a -> Moment (b, Future c) -> MomentIO (Event b, a -> IO c).

@ChristopherKing42
Copy link
Author

Also, it is currently possible to write combinators like this using MVars, but might thread lock if you do it in the wrong order. By including it in the library, the users do not need to reinvent the wheel each time (and could perhaps be made more efficient).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant