Functional Reactive Programming with nothing but Promises
27 October 2015
Functional Reactive Programming (FRP) is a model of reactive programming distinguished by having a well-defined semantics given by time-indexed values. Promises are one-shot communication channels which allow asynchronous programs to be written in a synchronous style. In this paper, we show how timed promise lists, a timestamped linked list structure using promises rather than pointers, can be used to implement FRP. This idea originated with Elliott's Push/Pull FRP, and we show that it can be expressed idiomatically in a strict functional language with promises, JavaScript. We identify a potential space leak with JavaScript's built-in promises and propose an alternative implementation that avoids the leak.