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 2014 Publication History

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

Cited By

View all

Index Terms

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

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 49, Issue 9
    ICFP '14
    September 2014
    361 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2692915
    Issue’s Table of Contents
    • cover image ACM Conferences
      ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programming
      August 2014
      390 pages
      ISBN:9781450328739
      DOI:10.1145/2628136
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 19 August 2014
    Published in SIGPLAN Volume 49, Issue 9

    Check for updates

    Author Tags

    1. arrowchoice
    2. arrows
    3. functional reactive programming
    4. switch

    Qualifiers

    • Research-article

    Funding Sources

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)7
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 13 Dec 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2020)The essence of live coding: change the program, keep the state!Proceedings of the 7th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems10.1145/3427763.3428312(2-14)Online publication date: 16-Nov-2020
    • (2020)A Timed IO MonadPractical Aspects of Declarative Languages10.1007/978-3-030-39197-3_9(131-147)Online publication date: 14-Jan-2020
    • (2024)Functional Reactive Programming, RearrangedProceedings of the 17th ACM SIGPLAN International Haskell Symposium10.1145/3677999.3678278(55-67)Online publication date: 29-Aug-2024
    • (2023)This Is Driving Me Loopy: Efficient Loops in Arrowized Functional Reactive ProgramsProceedings of the 16th ACM SIGPLAN International Haskell Symposium10.1145/3609026.3609726(3-17)Online publication date: 30-Aug-2023
    • (2019)Synthesizing functional reactive programsProceedings of the 12th ACM SIGPLAN International Symposium on Haskell10.1145/3331545.3342601(162-175)Online publication date: 8-Aug-2019
    • (2019)Screaming in the IO monad: a realtime audio processing and control experiment in HaskellProceedings of the 7th ACM SIGPLAN International Workshop on Functional Art, Music, Modeling, and Design10.1145/3331543.3342585(71-82)Online publication date: 23-Aug-2019
    • (2018)A Simple Context-Oriented Programming Extension to an FRP Language for Small-Scale Embedded SystemsProceedings of the 10th ACM International Workshop on Context-Oriented Programming: Advanced Modularity for Run-time Composition10.1145/3242921.3242925(23-30)Online publication date: 16-Jul-2018
    • (2016)Structured reactive programming with polymorphic temporal tilesProceedings of the 4th International Workshop on Functional Art, Music, Modelling, and Design10.1145/2975980.2975984(29-40)Online publication date: 10-Sep-2016

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media