FrTime: Functional Reactive Programming in PLT Scheme
📜 Abstract
Functional Reactive Programming (FRP) supports the declarative construction of reactive systems through signals, or time-varying values. In this paper, we present a new language called FrTime, which provides FRP-style signals atop a dialect of Scheme. We introduce the language with a few examples and discuss its implementation. FrTime uses impure features, such as state and asynchronous communication, to model time and to control evaluation. The use of such features yields a scalable, event-driven implementation with several important advantages. Specifically, it eases integration with other systems, supports distribution of signals across a network, and permits various benign impurities. To illustrate the language’s expressive power, we present a concise implementation of a networked, multi-player paddle-ball game in FrTime.
✨ Summary
Overview
The paper presents FrTime, a Scheme-based implementation of Functional Reactive Programming (FRP) integrated into the DrScheme environment. FrTime extends a mostly functional subset of PLT Scheme with signals, which represent time-varying values. Signals are divided into behaviors, which have values continuously available over time, and events, which represent discrete occurrences such as keystrokes, mouse actions, or network messages.
Core programming model
FrTime automatically lifts primitive function applications over behaviors, allowing programmers to combine constants and time-varying values using ordinary Scheme expressions. Events are processed with combinators such as mapping, filtering, merging, accumulation, and holding the latest occurrence as a behavior. This model lets programmers describe dependencies declaratively rather than manually updating state and coordinating callbacks.
The paper demonstrates the model with clocks, animations, interactive graphics, mutable parameter cells, and a networked multiplayer paddle-ball game. The game uses behaviors for positions and scores, events for collisions and updates, and remote events for communication between machines.
Implementation
Unlike earlier FRP implementations based primarily on pure functional techniques and synchronous evaluation, FrTime represents each signal with a mutable data structure containing an update procedure and its most recently computed value. A signal manager maintains the dependency graph and processes asynchronous messages through a queue. Updates propagate from changed signals to dependent signals in a breadth-first, bottom-up order. Timed signals use an alarm queue, while optimizations avoid propagating unchanged values and prevent duplicate scheduling.
This design introduces brief periods in which related behaviors may be inconsistent. The authors treat this as a deliberate engineering trade-off and identify model checking and limited synchronization mechanisms as possible ways to improve reasoning and robustness.
Main contributions and implications
The implementation strategy provides four concrete benefits:
- Distributed signals: Events can be transmitted as messages and exposed through local proxies on other machines.
- System integration: Asynchronous message queues allow external GUI libraries and other imperative systems to provide input and consume signal updates without polling.
- Resource efficiency: Event-driven propagation performs work in proportion to the rate of actual changes rather than recomputing the entire signal network at a fixed global sampling rate. The reported experiments show advantages for large systems with heterogeneous update frequencies.
- Benign impurity: Mutation, input/output, imperative drawing, and mutable cells can be used while preserving automatic propagation of dependent signal values. This supports interactive experimentation and querying current behavior values from the development environment.
Influence and subsequent use
The work was followed by research that developed FrTime’s design and semantic foundations more fully. The authors’ later paper, Embedding Dynamic Dataflow in a Call-by-Value Language, describes FrTime as an embedding of dynamic dataflow in Scheme, presents a formal evaluation model, and discusses incremental program construction and integration with existing code. (static.cs.brown.edu) The FrTime language remains documented and packaged in the Racket ecosystem; the current documentation explicitly lists this 2004 paper alongside later papers as a design reference. (plt.cs.northwestern.edu)
Related work also applied FrTime to practical GUI integration by adapting the MrEd object-oriented toolkit and developing a spreadsheet prototype. (cs.brown.edu) A later master’s thesis used FrTime as the reactive foundation for real-time computer musical performers, demonstrating application beyond graphics and user interfaces. (digitalcommons.calpoly.edu) The available evidence therefore indicates sustained influence on subsequent FRP research, Racket tooling, GUI integration, and experimental interactive applications, but does not establish broad industrial adoption.