Settable and Non-Interfering Signal Functions for FRP


Daniel Winograd-Cort Paul Hudak


Functional Reactive Programming (FRP) provides a method for programming continuous, reactive systems by utilizing signal functions that, abstractly, transform continuous input signals into continuous output signals. These signals may also be streams of events, and indeed, by allowing signal functions themselves to be the values carried by these events (in essence, signals of signal functions), one can conveniently make discrete changes in program behavior by ``switching'' into and out of these signal functions. This higher-order notion of switching is common among many FRP systems, in particular those based on arrows, such as Yampa.

Although convenient, the power of switching is often an overkill and can pose problems for certain types of program optimization (such as causal commutative arrows), as it causes the structure of the program to change dynamically at run-time. Without a notion of just-in-time compilation or related idea, which itself is beset with problems, such optimizations are not possible at compile time.

This paper introduces two new ideas that obviate, in a predominance of cases, the need for switching. The first is a non-interference law for arrows with choice that allows an arrowized FRP program to dynamically alter its own structure (within statically limited bounds) as well as abandon unused streams. The other idea is a notion of a settable signal function that allows a signal function to capture its present state and later be restarted from some previous state. With these two features, canonical uses of higher-order switchers can be replaced with a suitable first-order design, thus enabling a broader range of static optimizations.


  author = {Winograd-Cort, Daniel and Hudak, Paul},
  title = {Settable and {N}on-{I}nterfering {S}ignal {F}unctions for {FRP}},
  booktitle = {ICFP},
  numpages = {13},
  pages = {213--225},
  publisher = {{ACM}},
  year = {2014},
  location = {Gotenberg, Sweden},
  month = {September}