Abstract
Functional Reactive Programming (FRP) provides a method for programming continuous, reactive systems by utilizing signal functions that, abstractly, transform continuous input signals into continuous output signals. These signals may also be streams of events, and indeed, by allowing signal functions themselves to be the values carried by these events (in essence, signals of signal functions), one can conveniently make discrete changes in program behavior by "switching" into and out of these signal functions. This higher-order notion of switching is common among many FRP systems, in particular those based on arrows, such as Yampa.
Although convenient, the power of switching is often an overkill and can pose problems for certain types of program optimization (such as causal commutative arrows [14]), as it causes the structure of the program to change dynamically at run-time. Without a notion of just-in-time compilation or related idea, which itself is beset with problems, such optimizations are not possible at compile time.
This paper introduces two new ideas that obviate, in a predominance of cases, the need for switching. The first is a non-interference law for arrows with choice that allows an arrowized FRP program to dynamically alter its own structure (within statically limited bounds) as well as abandon unused streams. The other idea is a notion of a settable signal function that allows a signal function to capture its present state and later be restarted from some previous state. With these two features, canonical uses of higher-order switchers can be replaced with a suitable first-order design, thus enabling a broader range of static optimizations.
- A. Courtney. Modelling User Interfaces in a Functional Language. PhD thesis, Department of Computer Science, Yale University, May 2004. Google Scholar
Digital Library
- A. Courtney and C. Elliott. Genuinely functional user interfaces. In 2001 Haskell Workshop, September 2001.Google Scholar
- A. Courtney, H. Nilsson, and J. Peterson. The Yampa arcade. In Haskell Workshop, Haskell '03, pages 7--18. ACM, August 2003. Google Scholar
Digital Library
- E. Czaplicki and S. Chong. Asynchronous functional reactive programming for GUIs. In PLDI, pages 411--422, 2013. Google Scholar
Digital Library
- C. Elliott. Functional implementations of continuous modeled animation. In Proceedings of PLILP/ALP '98. Springer-Verlag, 1998. Google Scholar
Digital Library
- C. Elliott and P. Hudak. Functional reactive animation. In International Conference on Functional Programming, pages 263--273. ACM, June 1997. Google Scholar
Digital Library
- C. Elliott, G. Schechter, R. Yeung, and S. Abi-Ezzi. TBAG: A high level framework for interactive, animated 3D graphics applications. In 21st Conference on Computer Graphics and Interactive Techniques, pages 421--434. ACM, July 1994. Google Scholar
Digital Library
- C. M. Elliott. Push-pull functional reactive programming. In Proceedings of the 2Nd ACM SIGPLAN Symposium on Haskell, Haskell '09, pages 25--36, New York, NY, USA, September 2009. ACM. Google Scholar
Digital Library
- P. Hudak. The Haskell School of Expression - Learning Functional Programming through Multimedia. Cambridge University Press, New York, NY, 2000. Google Scholar
Digital Library
- P. Hudak. The Haskell School of Music - From Signals to Symphonies. (Version 2.6), January 2014.Google Scholar
- P. Hudak, A. Courtney, H. Nilsson, and J. Peterson. Arrows, robots, and functional reactive programming. In Summer School on Advanced Functional Programming 2002, Oxford University, volume 2638 of Lecture Notes in Computer Science, pages 159--187. Springer-Verlag, August 2003.Google Scholar
- J. Hughes. Generalising monads to arrows. Science of Computer Programming, 37(1-3):67--111, May 2000. Google Scholar
Digital Library
- S. Lindley, P. Wadler, and J. Yallop. The arrow calculus. Journal of Functional Programming, 20(1):51--69, January 2010. Google Scholar
Digital Library
- H. Liu, E. Cheng, and P. Hudak. Causal commutative arrows. Journal of Functional Programming, 21(4-5):467--496, September 2011. Google Scholar
Digital Library
- P. Liu and P. Hudak. Plugging a space leak with an arrow. Electronic Notes in Theoretical Computer Science, 193(1):29--45, November 2007. Google Scholar
Digital Library
- G. Patai. Efficient and compositional higher-order streams. In Proceedings of the 19th International Conference on Functional and Constraint Logic Programming, WFLP'10, pages 137--154, Berlin, Heidelberg, 2011. Springer-Verlag. Google Scholar
Digital Library
- R. Paterson. A new notation for arrows. In Sixth International Conference on Functional Programming, pages 229--240. ACM, September 2001. Google Scholar
Digital Library
- A. Voellmy and P. Hudak. Nettle: Taking the sting out of programming network routers. In Practical Aspects of Declarative Languages, volume 6539 of Lecture Notes in Computer Science. Springer-Verlag, January 2011. Google Scholar
Digital Library
- D. Winograd-Cort and P. Hudak. Wormholes: Introducing Effects to FRP. In Haskell Symposium, pages 91--103. ACM, September 2012. Google Scholar
Digital Library
Index Terms
Settable and non-interfering signal functions for FRP: how a first-order switch is more than enough
Recommendations
Settable and non-interfering signal functions for FRP: how a first-order switch is more than enough
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programmingFunctional Reactive Programming (FRP) provides a method for programming continuous, reactive systems by utilizing signal functions that, abstractly, transform continuous input signals into continuous output signals. These signals may also be streams of ...
LTL types FRP: linear-time temporal logic propositions as types, proofs as functional reactive programs
PLPV '12: Proceedings of the sixth workshop on Programming languages meets program verificationFunctional Reactive Programming (FRP) is a form of reactive programming whose model is pure functions over signals. FRP is often expressed in terms of arrows with loops, which is the type class for a Freyd category (that is a premonoidal category with a ...
Scripted signal functions
Haskell 2020: Proceedings of the 13th ACM SIGPLAN International Symposium on HaskellProgramming time-dependent signals like animations involves expressing both continuous and discrete changes in signal values. The method of functional reactive programming (FRP) represents this simply and effectively as discrete modes of an otherwise ...







Comments