While reading about and implementing FRP I am confused by the semantics of the occs function on Event (referred to in Conal Elliott’s papers). It is very simple when dealing with static (pure) Events but I don’t understand how it works with dynamic Events (such as mouse button presses etc). For instance, if occs returns all of the occurrences of an Event then as far as I can see a result for occs for a dynamic Event could be one of the following things (since not all occurrences are known yet):
- The known occurrences at the time of the call
- An array/list that is automatically kept up to date with the Event itself
Of course both of these seem slightly ugly – one breaks semantic purity and the other involves side effects.
Would it be better to simply remove the occs function outside of the FRP framework itself (ie make it private to Event and anything that extends it)? As long as Event has map, filter, merge etc functions that return further Events I feel it could be lost without trouble. Or, am I misunderstanding something?
As far as I understand the
occsfunction mentioned in Conal’s paper is not part of the API. Rather, it’s a specification of the programming model. Conal uses it to describe the semantics of the various combinators, but it’s not something that you can or should implement.