## Higher-Order Functional Reactive Programming in Bounded Space

### Cached

### Download Links

Citations: | 4 - 1 self |

### BibTeX

@MISC{Krishnaswami_higher-orderfunctional,

author = {Neelakantan R. Krishnaswami and Nick Benton and Jan Hoffmann},

title = {Higher-Order Functional Reactive Programming in Bounded Space},

year = {}

}

### OpenURL

### Abstract

Functional reactive programming (FRP) is an elegant and successful approach to programming reactive systems declaratively. The high levels of abstraction and expressivity that make FRP attractive as a programming model do, however, often lead to programs whose resource usage is excessive and hard to predict. In this paper, we address the problem of space leaks in discretetime functional reactive programs. We present a functional reactive programming language that statically bounds the size of the dataflow graph a reactive program creates, while still permitting use of higher-order functions and higher-type streams such as streams of streams. We achieve this with a novel linear type theory that both controls allocation and ensures that all recursive definitions are well-founded. We also give a denotational semantics for our language by combining recent work on metric spaces for the interpretation of higher-order causal functions with length-space models of spacebounded computation. The resulting category is doubly closed and hence forms a model of the logic of bunched implications.

### Citations

1273 | The Temporal Logic of Programs - Pnueli - 1977 |

313 | Results on the propositional µ-calculus - Kozen - 1983 |

221 | A Powerdomain Construction - Plotkin - 1976 |

218 | A New Approach to Abstract Syntax with Variable Binding (journal version - Gabbay, Pitts |

214 | Functional reactive animation
- Elliott, Hudak
- 1997
(Show Context)
Citation Context ...ounded usage of space and time, and are widely used in applications such as hardware synthesis and embedded control software. Functional reactive programming (FRP), as introduced by Elliott and Hudak =-=[8]-=-, also works with time-varying values (rather than mutable state) as a primitive abstraction, but provides a much richer model than the synchronous languages: signals (behaviours) can vary continuousl... |

191 | The logic of bunched implications
- O’Hearn, Pym
- 1999
(Show Context)
Citation Context ...s good spatial behaviour, bounding the number of cells in the dataflow graph. The category of complete ultrametric length spaces is doubly-closed, forming a model of the logic of bunched implications =-=[20]-=- and exposing a (perhaps) surprising connection between the type theory of stream programming and separation logic. We define a term language, with a rather novel type theory, that corresponds to our ... |

174 | Generalising monads to arrows
- Hughes
- 2000
(Show Context)
Citation Context ...ing restrictions on the classic FRP model. The Yale Haskell Group’s Yampa [11, 19], for example, is an embedded DSL for FRP that constructs signal processing networks using Hughes’s arrow abstraction =-=[12]-=-. Signals are no longer first-class, and signal-processing functions must be built from well-behaved casual primitives by causality-preserving combinators. Arrowized FRP allows signals to carry comple... |

137 | An indexed model of recursive types for foundational proofcarrying code - Appel, McAllester - 2001 |

111 | Operational reasoning for functions with local state - Pitts, Stark - 1998 |

96 |
The ESTEREL synchronous programming language and its mathematical semantics. volume 197
- Berry, Cosserat
- 1984
(Show Context)
Citation Context ...○ 2012 ACM 978-1-4503-1083-3/12/01. . . $10.00 search into domain-specific languages (DSL), libraries and analysis techniques for reactive programming. Synchronous dataflow languages, such as Esterel =-=[3]-=-, Lustre [4], and Lucid Synchrone [21], implement a domain-specific computational model deriving from Kahn networks. A program corresponds to a fixed network of stream-processing nodes that communicat... |

90 | Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control - Miller - 2006 |

89 | A type system for bounded space and functional in-place update
- Hofmann
- 2000
(Show Context)
Citation Context ... the problem of such leaks by extending the ultrametric approach to FRP with linearly-typed resources that represent the permission to perform heap-allocation, following the pattern of Hofmann’s work =-=[9, 10]-=- on non-size-increasing computation. We give a denotational model for bounded higher-order reactive programming in terms of ‘complete ultrametric length spaces’, which carry both an ultrametric distan... |

78 | The incremental garbage collection of processes - Baker, Hewitt - 1977 |

73 | Linear types and non-size-increasing polynomial time computation
- Hofmann
(Show Context)
Citation Context ... the problem of such leaks by extending the ultrametric approach to FRP with linearly-typed resources that represent the permission to perform heap-allocation, following the pattern of Hofmann’s work =-=[9, 10]-=- on non-size-increasing computation. We give a denotational model for bounded higher-order reactive programming in terms of ‘complete ultrametric length spaces’, which carry both an ultrametric distan... |

63 | State-dependent representation independence - Ahmed, Dreyer, et al. - 2009 |

61 | Synchronous Kahn Networks - Caspi, Pouzet - 1996 |

56 |
Functional reactive programming, continued
- Nilsson, Courtney, et al.
- 2002
(Show Context)
Citation Context ...e entire history of a signal. 1 Subsequent research has attempted to reduce ‘junk’ and alleviate performance problems by imposing restrictions on the classic FRP model. The Yale Haskell Group’s Yampa =-=[11, 19]-=-, for example, is an embedded DSL for FRP that constructs signal processing networks using Hughes’s arrow abstraction [12]. Signals are no longer first-class, and signal-processing functions must be b... |

55 | Arrows, robots, and functional reactive programming - Hudak, Courtney, et al. - 2003 |

43 |
LUSTRE: a Declarative Language for Real-Time Programming
- Caspi, Pilaud, et al.
- 1987
(Show Context)
Citation Context ...78-1-4503-1083-3/12/01. . . $10.00 search into domain-specific languages (DSL), libraries and analysis techniques for reactive programming. Synchronous dataflow languages, such as Esterel [3], Lustre =-=[4]-=-, and Lucid Synchrone [21], implement a domain-specific computational model deriving from Kahn networks. A program corresponds to a fixed network of stream-processing nodes that communicate with one a... |

39 | Embedding dynamic dataflow in a call-by-value language
- Cooper, Krishnamurthi
- 2006
(Show Context)
Citation Context ...dality is simpler but less flexible, since it cannot depend on the values a signal produces. However, the advantage of our modality is that it works smoothly at higher-order. Cooper and Krishnamurthi =-=[6]-=- described the FrTime system, which embeds FRP into the PLT Scheme (now Racket) implementation. One commonality between FrTime and our work is that switching does not come from special primitives, but... |

37 |
A very modal model of a modern, major, general type system
- Appel, Melliès, et al.
- 2007
(Show Context)
Citation Context ...ne context and function space, so that operations like in-place map can be typed !(A → B) → S(A) −⋆S(B). Our language contains an explicit delay modality (as in logical presentations of step-indexing =-=[2, 7, 18]-=-) and an update-based operational semantics. The reader may find it surprising that, although our operational semantics does make use of a form of mutable higher-order store, the logical relation we g... |

37 | Self-Adjusting Computation - Acar - 2005 |

33 | Real-time FRP
- Wan, Taha, et al.
- 2001
(Show Context)
Citation Context ...ordinary functional evaluation. This explains why we were able to present a two-phase semantics, and since no heap modifications take place during ticks, there is no need for stepindexing. Wan et al. =-=[25]-=- introduced real-time FRP; a restricted subset of FRP sharing many of the same design choices of synchronous dataflow languages. It is essentially first-order (streams can carry general values of the ... |

32 | The impact of higher-order state and control effects on local relational reasoning - Dreyer, Neis, et al. - 2012 |

26 | A modality for recursion
- Nakano
(Show Context)
Citation Context ...ltrametric spaces, identifying causal functions with nonexpansive maps and interpreting well-founded feedback via Banach’s fixpoint theorem. They gave an associated language, featuring a Nakano-style =-=[18]-=- temporal modality for well-founded recursion, and showed the correctness of an implementation using an imperatively-updated dataflow graph. This implementation is much more efficient than directly ru... |

23 | Event driven FRP
- Wan, Taha, et al.
- 2002
(Show Context)
Citation Context ...s use of a novel continuation typing to ensure that all recursive signals are tail-recursive. As a result, the language requires only constant-stack and constant-time FRP reductions. Event-driven FRP =-=[26]-=- is similar, but relaxes FRP’s timing constraints by dropping the global clock. None of our examples using higher-order functions or nested streams can be programmed in real-time FRP, which is careful... |

21 |
Lucid Synchrone, version 3. Tutorial and reference manual
- Pouzet
- 2006
(Show Context)
Citation Context ... . $10.00 search into domain-specific languages (DSL), libraries and analysis techniques for reactive programming. Synchronous dataflow languages, such as Esterel [3], Lustre [4], and Lucid Synchrone =-=[21]-=-, implement a domain-specific computational model deriving from Kahn networks. A program corresponds to a fixed network of stream-processing nodes that communicate with one another, each consuming and... |

20 | How to add laziness to a strict language, without even being odd - Wadler, Taha, et al. - 1998 |

19 | The essence of dataflow programming
- Uustalu, Vene
- 2005
(Show Context)
Citation Context ...s )), u ’. let ys’ = tail (ys) in unflip (• ys ’) u’) The cokleisli function lifts a function from streams S(A) to a type B to a function from streams of A to streams of B, giving a comonad structure =-=[24]-=- to the S(·) functor. The flip and unflip functions define an isomorphism between streams of delayed values and delayed streams of values. These operations make use of the ability to explicitly delay ... |

16 | Logical step-indexed logical relations
- Dreyer, Ahmed, et al.
- 2009
(Show Context)
Citation Context ...ne context and function space, so that operations like in-place map can be typed !(A → B) → S(A) −⋆S(B). Our language contains an explicit delay modality (as in logical presentations of step-indexing =-=[2, 7, 18]-=-) and an update-based operational semantics. The reader may find it surprising that, although our operational semantics does make use of a form of mutable higher-order store, the logical relation we g... |

13 |
Quantitative models and implicit complexity
- Lago, Hofmann
- 2005
(Show Context)
Citation Context ...the Cartesian exponential A ⇒ B which does. A difference between our work and earlier work on length spaces is our heavy use of the category’s Cartesian closed structure. Indeed, dal Lago and Hofmann =-=[15]-=- use a realizability model to remove the Cartesian closed structure from their semantics — they wished to prevent duplicated variables in lambda-terms from enabling large increases in the size of a la... |

13 | Space profiling for parallel functional programs
- Spoonhower, Blelloch, et al.
- 2008
(Show Context)
Citation Context ...grows without bound, but is nevertheless accepted by our language’s type system. By design, we allow all ordinary call-by-value functional programs (which have reasonable compositional cost semantics =-=[23]-=-), and only use typing to track the unusual memory leaks of FRP. Hence our types only track the size of the dataflow graph (i.e., the number of live cons cells).3. Syntax and Typing We give the types... |

13 | Type-Safe Distributed Programming with ML5, volume 4912 - Murphy, Crary, et al. - 2008 |

12 | Safe functional reactive programming through dependent types
- Sculthorpe, Nilsson
- 2009
(Show Context)
Citation Context ... Interpretation of Types and Contexts of higher-order streams and functions, but it would nonetheless be interesting to investigate related optimizations in our setting. Sculthorpe and Nilsson’s work =-=[22]-=- on safe functional programming uses Agda’s types to ensure productivity, by having dependent types track whether signal processors have delays before permitting feedback. Our guardedness modality is ... |

11 |
Integrating dataflow evaluation into a practical higher-order call-by-value language
- COOPER
(Show Context)
Citation Context ... between FrTime and our work is that switching does not come from special primitives, but from ordinary conditionals and case statements. Unlike our denotational model, Cooper’s operational semantics =-=[5]-=- exemplifies the “imperative FRP” tradition, in which reactivity is modelled explicitly as [[Θ ⊢ t :i R]]i ∈ [[Θ]i → [[R]] [[Θ; Π; Γ ⊢ e :i A]]i ∈ [[Θ]i⋆![[Π]i ⋆ [[Γ]i → [[A]] [[Θ ⊢ u :j R]]i θ = θ(u)... |

10 | Causal commutative arrows and their optimization
- Liu, Cheng, et al.
- 2009
(Show Context)
Citation Context ... written in our language, since we can define all of real-time FRP’s stream operators (switching, delays, multimodal recursion) as ordinary user-level programs. Liu et al.’s causal commutative arrows =-=[17]-=- are another attempt to control the memory and space usage of reactive programs. This work takes advantage of the fact that pure arrowized FRP (i.e., without switching) builds fixed dataflow graphs, a... |

10 | The Impact of Applicative Programming on Multiprocessing - Friedman, Wise - 1976 |

9 | Ultrametric semantics of reactive programs
- Krishnaswami, Benton
(Show Context)
Citation Context ...an arbitrarily lengthy computation to ‘catch up’ with the current time.ity or provide resource guarantees but, empirically at least, makes certain kinds of leaks less likely. Krishnaswami and Benton =-=[13]-=- recently described a semantic model for higher-order, discrete-time functional reactive programs based on ultrametric spaces, identifying causal functions with nonexpansive maps and interpreting well... |

9 | A consistent semantics of self-adjusting computation - Acar, Blume, et al. - 2007 |

8 | A semantic model for graphical user interfaces
- Krishnaswami, Benton
- 2011
(Show Context)
Citation Context ...rative in flavour, is close enough to both a denotational model and Cooper’s semantics that it makes sense to study how to reunify the pure and the imperative flavours of FRP. Krishnaswami and Benton =-=[14]-=- have also presented a language for writing reactive GUI programs. This language also makes use of linear types, but in this case they are used to track the allocation of new GUI widgets. It is not ye... |

6 | Traceable data types for self-adjusting computation
- Acar, Blelloch, et al.
(Show Context)
Citation Context ... by moving to a category of metric spaces. A complete 1-bounded bisected ultrametric space A (which we will simply call “ultrametric space”) is a pair (|A|, d), where |A| is a set and d ∈ |A| × |A| → =-=[0, 1]-=- is a distance function satisfying the following properties: 1. d(x, y) = 0 iff x = y 2. d(x, y) = d(y, x) 3. d(x, z) ≤ max(d(x, y), d(y, z)) 4. d(x, y) = 0 or 2 −n for some n 5. All Cauchy sequences ... |

6 | LTL types FRP: linear-time temporal logic propositions as types, proofs as functional reactive programs - Jeffrey - 2012 |

3 | The Paradox of Kleene and Rosser - Curry - 1941 |

3 | Towards a common categorical semantics for linear-time temporal logic and functional reactive programming - Jeltsch |

3 | S.: Modeling and reasoning about DOM events - Lerner, Carroll, et al. - 2012 |

3 | Deprecating the Observer Pattern with Scala.react - Maier, Odersky - 2012 |

3 | Keeping calm in the face of change - Sculthorpe, Nilsson |

2 | Froc: a library for functional reactive programming in OCaml - Donham - 2010 |

2 | Temporal logic with until: Functional reactive programming with processes and concrete process categories - Jeltsch - 2013 |

2 | Higher-order reactive programming without spacetime leaks - Krishnaswami - 2013 |