skip to main content
research-article

Settable and non-interfering signal functions for FRP: how a first-order switch is more than enough

Published:19 August 2014Publication History
Skip Abstract Section

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.

References

  1. A. Courtney. Modelling User Interfaces in a Functional Language. PhD thesis, Department of Computer Science, Yale University, May 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. Courtney and C. Elliott. Genuinely functional user interfaces. In 2001 Haskell Workshop, September 2001.Google ScholarGoogle Scholar
  3. A. Courtney, H. Nilsson, and J. Peterson. The Yampa arcade. In Haskell Workshop, Haskell '03, pages 7--18. ACM, August 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. E. Czaplicki and S. Chong. Asynchronous functional reactive programming for GUIs. In PLDI, pages 411--422, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. C. Elliott. Functional implementations of continuous modeled animation. In Proceedings of PLILP/ALP '98. Springer-Verlag, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. Elliott and P. Hudak. Functional reactive animation. In International Conference on Functional Programming, pages 263--273. ACM, June 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. P. Hudak. The Haskell School of Expression - Learning Functional Programming through Multimedia. Cambridge University Press, New York, NY, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. P. Hudak. The Haskell School of Music - From Signals to Symphonies. (Version 2.6), January 2014.Google ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar
  12. J. Hughes. Generalising monads to arrows. Science of Computer Programming, 37(1-3):67--111, May 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. Lindley, P. Wadler, and J. Yallop. The arrow calculus. Journal of Functional Programming, 20(1):51--69, January 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. H. Liu, E. Cheng, and P. Hudak. Causal commutative arrows. Journal of Functional Programming, 21(4-5):467--496, September 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. R. Paterson. A new notation for arrows. In Sixth International Conference on Functional Programming, pages 229--240. ACM, September 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. D. Winograd-Cort and P. Hudak. Wormholes: Introducing Effects to FRP. In Haskell Symposium, pages 91--103. ACM, September 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Settable and non-interfering signal functions for FRP: how a first-order switch is more than enough

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!