-1

Is this 120 lines of code fully and completly describes Reactive Banana's semantics ?

https://github.com/HeinrichApfelmus/reactive-banana/blob/develop/reactive-banana/src/Reactive/Banana/Model.hs

Can this 120 lines of code be considered as a denotational semantics for FRP ?

Does this 120 loc provide the same functionality as say Sodium's 1000 loc?

Is there a simple FRP demo that uses this model implementation ? Like a paddleball game ? Or lunar launcher game ? Or a 2D solar system simulator?

I would love to see some reactive demo that is using this 120 loc FRP implentation.

Can I somehow modify existing Reactive Banana demos to use this 120 loc model implementation instead of the Prim implementation ?

This example for example seems to be using the Prim implementation: https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana/doc/examples/SlotMachine.hs

Is it possible to modify it to use the Model implementation ?

jhegedus
  • 20,244
  • 16
  • 99
  • 167

1 Answers1

2

(Author here.) The model implementation does indeed provide a (denotational) semantics for functional reactive programming as implemented by reactive-banana.

However, it is the nature of denotational semantics that it specifies what a program calculates, but not how fast. The model implementation is rather inefficient, in particular the parts involving dynamic event switching. The meat of the reactive-banana library is an efficient implementation of the semantics provided by the model implementation.

Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67
  • Thank you for the answer. I understand that the reference implementation is not super efficient. For educational purposes however it would be lovely to see how I can use the model implementation for the Slotmachine example: https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana/doc/examples/SlotMachine.hs, how can I modify Slotmachine.hs so that it uses the model implementation? I am a beginner with reactive banana and understanding how the model implementation works in the Slotmachine example would be helpful in understanding reactive banana. – jhegedus Feb 04 '15 at 08:14
  • In other words, if you could put up to github a version of Slotmachine.hs that uses the model implementation that would be very educational because the semantics of the efficient implementation (Prim) is difficult to understand just by reading the code. So, it would be motivating to see the model implementation in action and at the same time understand the whole code (Statemachine.hs and the model implementation of your FRP library), could you please put up such a modified version of Statemachine.hs to github if you have some time? – jhegedus Feb 04 '15 at 08:21
  • Well, another problem with the model implementation is that it does not have a `fromAddHandler` combinator. If you want to compare both implementations, I recommend to have a look at the internal [Reactive.Banana.test](https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana%2Fsrc%2FReactive%2FBanana%2FTest.hs) module. I'll look into posting more educational materials, but I can't promise anything at the moment. – Heinrich Apfelmus Feb 04 '15 at 12:48
  • I see, so it is not so easy to just swap the Prim implementation to the Model implementation in the Statemachine.hs ? No rush, I was just thinking how nice it would be to see the actual denotational semantics of FRP in action on a super simple example. It is a little bit like a model airplane for a child. – jhegedus Feb 04 '15 at 16:54