How can such system handle actual user interaction?
. To my understanding it doesn't. The mathemation has their T->mousePos
, etc. already predefined to demonstrate the model. Like a prerecording to test the model on.
In Mathematics there are no side effects. And I believe they are providing the mathematical model of FRP, to be understood by other mathematicians. It is by no means how'd you would actually implemented it in the end. Implementing FRP using pure functional programming (just like how the mathematics is completely pure), then your end performance will suffer quiet a bit.
Mathematically to show a value of type a
that varies of over time (a mutable variable) is like so T -> a
. Its says I'm a pure functions such that if you feed me any wall clock time, then I will give you the value of that variable at that time. (Its just how mathematicians do side effects)
When ever you see T -> a
from the mathematicians side, then you generally see IO a
on the programmers side (at least in Haskell). The "MomentMonad m", has the capabilities of "IO", except that it also passes additional pumping state throughout the program for doing transactions and for maintaining ranks, listeners (keep alive pool for the strong listeners), etc.
There is no global mutable state in Haskell, so you have to keep passing references to your mutable stage along as the code executes. That is why it is "MomentMonad m" instead of "IO". (To hide the passing of mutable state away from the programmer.)
Since monads and high order generics are god awful to do in most mainstream languages, we have a global state for the transactions and transactions are handled via the Transaction singleton object. It is the imperative solution to the "MomentMonad m".
Just because the machinery under the hood is imperative, does not mean all of SodiumFRP is imperative. Most parts of SodiumFRP's interface are pure in an unobservable side-effects kind of way. (Sort of like you can have local-side effects in functions, and still have those functions behave in a pure way to their external environment.)
What matters is the implementation and mathematics are equivalent in an analog way.
I've honestly never seen switcher
before, but I do not believe it will hold any real benefit over Sodium's switchC
. Some cases your code might be longer, some cases your code might be sorter. Mileage will vary.