Higher-order functional reactive programming without spacetime leaks

Functional reactive programming (FRP) is an elegant approach to declaratively specify reactive systems. However, the powerful abstractions of FRP have historically made it difficult to predict and control the resource usage of programs written in this style. In this paper, we give a new language for higher-order reactive programming. Our language generalizes and simplifies prior type systems for reactive programming, by supporting the use of streams of streams, first-class functions, and higher-order operations. We also support many temporal operations beyond streams, such as terminatable streams, events, and even resumptions with first-class schedulers. Furthermore, our language supports an efficient implementation strategy permitting us to eagerly deallocate old values and statically rule out spacetime leaks, a notorious source of inefficiency in reactive programs. Furthermore, these memory guarantees are achieved without the use of a complex substructural type discipline. We also show that our implementation strategy of eager deallocation is safe, by showing the soundness of our type system with a novel step-indexed Kripke logical relation.

[1]  Shriram Krishnamurthi,et al.  Modeling and Reasoning about DOM Events , 2012, WebApps.

[2]  Derek Dreyer,et al.  State-dependent representation independence , 2009, POPL '09.

[3]  Martin Hofmann,et al.  Linear types and non-size-increasing polynomial time computation , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[4]  I. Stark,et al.  Operational reasoning for functions with local state , 1999 .

[5]  Wolfgang Jeltsch Temporal logic with "Until", functional reactive programming with processes, and concrete process categories , 2013, PLPV '13.

[6]  Fred Kröger,et al.  Temporal Logic of Programs , 1987, EATCS Monographs on Theoretical Computer Science.

[7]  Paul Hudak,et al.  Causal commutative arrows and their optimization , 2009, ICFP.

[8]  Conal Elliott,et al.  Push-pull functional reactive programming , 2009, Haskell.

[9]  Lars Birkedal,et al.  The impact of higher-order state and control effects on local relational reasoning , 2012, J. Funct. Program..

[10]  Wolfgang Jeltsch,et al.  Towards a Common Categorical Semantics for Linear-Time Temporal Logic and Functional Reactive Programming , 2012, MFPS.

[11]  Shriram Krishnamurthi,et al.  Embedding Dynamic Dataflow in a Call-by-Value Language , 2006, ESOP.

[12]  Lucid Synchrone,et al.  Tutorial and Reference Manual , 2007 .

[13]  Nick Benton,et al.  Ultrametric Semantics of Reactive Programs , 2011, 2011 IEEE 26th Annual Symposium on Logic in Computer Science.

[14]  Alan Jeffrey,et al.  Causality for free!: parametricity implies causality for functional reactive programs , 2013, PLPV.

[15]  Robert Harper,et al.  Self-adjusting computation , 2004, Proceedings of the 19th Annual IEEE Symposium on Logic in Computer Science, 2004..

[16]  Martin Odersky,et al.  Deprecating the Observer Pattern with Scala.React , 2012 .

[17]  Henrik Nilsson,et al.  Keeping calm in the face of change , 2010, High. Order Symb. Comput..

[18]  Paul Hudak,et al.  Functional reactive animation , 1997, ICFP '97.

[19]  Gordon D. Plotkin,et al.  A Powerdomain Construction , 1976, SIAM J. Comput..

[20]  Wolfgang Jeltsch Signals, Not Generators! , 2009, Trends in Functional Programming.

[21]  Nick Benton,et al.  Higher-order functional reactive programming in bounded space , 2012, POPL '12.

[22]  Andrew W. Appel,et al.  An indexed model of recursive types for foundational proof-carrying code , 2001, TOPL.

[23]  Gérard Berry,et al.  The ESTEREL Synchronous Programming Language and its Mathematical Semantics , 1984, Seminar on Concurrency.

[24]  Paul Hudak,et al.  Event-Driven FRP , 2002, PADL.

[25]  Nick Benton,et al.  A semantic model for graphical user interfaces , 2011, ICFP.

[26]  Nicolas Halbwachs,et al.  LUSTRE: a declarative language for real-time programming , 1987, POPL '87.

[27]  Marc Pouzet,et al.  Synchronous Kahn networks , 1996, ICFP '96.

[28]  Henrik Nilsson,et al.  Safe functional reactive programming through dependent types , 2009, ICFP.

[29]  Robert Harper Self-adjusting computation , 2004, LICS 2004.

[30]  Gregory H. Cooper,et al.  Integrating Dataflow Evaluation into a Practical Higher-Order Call-by-Value Language , 2008 .

[31]  Prakash Panangaden,et al.  Fair reactive programming , 2014, POPL.

[32]  Karl Crary,et al.  Type-Safe Distributed Programming with ML5 , 2007, TGC.

[33]  Hiroshi Nakano,et al.  A modality for recursion , 2000, Proceedings Fifteenth Annual IEEE Symposium on Logic in Computer Science (Cat. No.99CB36332).

[34]  Henrik Nilsson,et al.  Functional reactive programming, continued , 2002, Haskell '02.

[35]  Haskell B. Curry,et al.  The paradox of Kleene and Rosser , 1941 .

[36]  Marc Pouzet,et al.  Lucid Synchrone - version 2.0: Tutorial and reference manual , 2001 .

[37]  Carl Hewitt,et al.  The incremental garbage collection of processes , 1977, Artificial Intelligence and Programming Languages.

[38]  Walid Taha,et al.  How to add laziness to a strict language without even being odd , 1998 .

[39]  Mark S. Miller,et al.  Robust composition: towards a unified approach to access control and concurrency control , 2006 .

[40]  Andrew M. Pitts,et al.  A New Approach to Abstract Syntax with Variable Binding , 2002, Formal Aspects of Computing.

[41]  Alan Jeffrey,et al.  LTL types FRP: linear-time temporal logic propositions as types, proofs as functional reactive programs , 2012, PLPV '12.

[42]  Dexter Kozen,et al.  Results on the Propositional µ-Calculus , 1982, ICALP.