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 discrete-time 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 space-bounded computation. The resulting category is doubly closed and hence forms a model of the logic of bunched implications.
Supplemental Material
- U. A. Acar, G. E. Blelloch, R. Ley-Wild, K. Tangwongsan, and D. Türkoglu. Traceable data types for self-adjusting computation. In PLDI, pages 483--496, 2010. Google ScholarDigital Library
- A. W. Appel, P.-A. Melliès, C. D. Richards, and J. Vouillon. A very modal model of a modern, major, general type system. In M. Hofmann and M. Felleisen, editors, POPL, pages 109--122. ACM, 2007. ISBN 1--59593--575--4. Google ScholarDigital Library
- G. Berry and L. Cosserat. The ESTEREL synchronous programming language and its mathematical semantics. In Seminar on Concurrency, pages 389--448. Springer, 1985. Google ScholarDigital Library
- P. Caspi, D. Pilaud, N. Halbwachs, and J. Plaice. LUSTRE: A declarative language for real-time programming. In POPL, 1987. Google ScholarDigital Library
- G. Cooper. Integrating dataflow evaluation into a practical higher-order call-by-value language. PhD thesis, Brown University, 2008. Google ScholarDigital Library
- G. Cooper and S. Krishnamurthi. Embedding dynamic dataflow in a call-by-value language. Programming Languages and Systems, pages 294--308, 2006. Google ScholarDigital Library
- D. Dreyer, A. Ahmed, and L. Birkedal. Logical step-indexed logical relations. In LICS, pages 71--80. IEEE, 2009. Google ScholarDigital Library
- C. Elliott and P. Hudak. Functional reactive animation. In ICFP, 1997. Google ScholarDigital Library
- M. Hofmann. A type system for bounded space and functional in-place update. Nordic Journal of Computing, 7 (4), 2000. Google ScholarDigital Library
- M. Hofmann. Linear types and non-size-increasing polynomial time computation. Information and Computation, 183 (1), 2003. Google ScholarDigital Library
- P. Hudak, A. Courtney, H. Nilsson, and J. Peterson. Arrows, robots and functional reactive programming. In Advanced Functional Programming, volume 2638 of LNCS. Springer, 2003.Google ScholarCross Ref
- J. Hughes. Generalizing monads to arrows. Sci. Comput. Program., 37 (1--3), 2000. Google ScholarDigital Library
- N. Krishnaswami and N. Benton. Ultrametric semantics of reactive programs. In LICS. IEEE, 2011. Google ScholarDigital Library
- N. Krishnaswami and N. Benton. A semantic model of graphical user interfaces. In ICFP, 2011. Google ScholarDigital Library
- U. D. Lago and M. Hofmann. Realizability models and implicit complexity. Theor. Comput. Sci., 412 (20): 2029--2047, 2011. Google ScholarDigital Library
- R. Ley-Wild, U. A. Acar, and M. Fluet. A cost semantics for self-adjusting computation. In Z. Shao and B. C. Pierce, editors, POPL, pages 186--199. ACM, 2009. ISBN 978--1--60558--379--2. Google ScholarDigital Library
- H. Liu, E. Cheng, and P. Hudak. Causal commutative arrows and their optimization. In ICFP, 2009. Google ScholarDigital Library
- H. Nakano. A modality for recursion. In LICS, pages 255--266, 2000. Google ScholarDigital Library
- H. Nilsson, A. Courtney, and J. Peterson. Functional reactive programming, continued. In ACM Haskell Workshop, pages 51--64. ACM, 2002. Google ScholarDigital Library
- P. W. O'Hearn and D. J. Pym. The logic of bunched implications. Bulletin of Symbolic Logic, 5 (2), 1999.Google Scholar
- M. Pouzet. Lucid Synchrone, version 3. Tutorial and reference manual. Université Paris-Sud, LRI, 2006.Google Scholar
- N. Sculthorpe and H. Nilsson. Safe functional reactive programming through dependent types. In ICFP, 2009. Google ScholarDigital Library
- D. Spoonhower, G. E. Blelloch, R. Harper, and P. B. Gibbons. Space profiling for parallel functional programs. In J. Hook and P. Thiemann, editors, ICFP, pages 253--264. ACM, 2008. ISBN 978--1--59593--919--7. Google ScholarDigital Library
- T. Uustalu and V. Vene. The essence of dataflow programming. In K. Yi, editor, APLAS, volume 3780 of Lecture Notes in Computer Science, pages 2--18. Springer, 2005. ISBN 3--540--29735--9. Google ScholarDigital Library
- Z. Wan, W. Taha, and P. Hudak. Real-time FRP. In ICFP, pages 146--156, 2001. Google ScholarDigital Library
- Z. Wan, W. Taha, and P. Hudak. Event-driven FRP. In PADL, pages 155--172, 2002. Google ScholarDigital Library
Index Terms
- Higher-order functional reactive programming in bounded space
Recommendations
Higher-order functional reactive programming without spacetime leaks
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingFunctional 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 ...
Higher-order functional reactive programming in bounded space
POPL '12Functional 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 ...
Higher-order functional reactive programming without spacetime leaks
ICFP '13Functional 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 ...
Comments