[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/3354166.3354172acmotherconferencesArticle/Chapter ViewAbstractPublication PagesppdpConference Proceedingsconference-collections
research-article

Functional Reactive Programming, restated

Published: 07 October 2019 Publication History

Abstract

Functional Reactive Programming is an approach to declarative programming of reactive systems by describing interactions between time-varying values. FRP implementations are often realised as an embedding in a functional host language, making for very expressive reactive programming frameworks. However, this expressiveness comes at a cost: current embedded FRP implementations incur substantial performance overheads, in particular for values that (notionally) vary continuously. The basic idea of FRP is closely related to synchronous data-flow and continuous system simulation languages. In contrast to FRP, these handle values that vary continuously efficiently, but are less expressive. This paper seeks to bridge this gap by proposing a novel approach to embedded FRP-implementation that uses the fundamental implementation approach of synchronous datalow and simulation languages for efficient handling of continuously varying values, while retaining the expressiveness normally associated with FRP, as well as paying attention to values that only change relatively infrequently. These ideas are applicable beyond FRP, for example for implementing flexible embedded simulation languages. We evaluate our approach on a range of benchmarks, including an existing full-fledged video game where using our new FRP implementation as a drop-in replacement for the old one gave a three-fold performance improvement.

References

[1]
Heinrich Apfelmus. [n. d.]. Reactive-Banana: Library for Functional Reactive Programming (FRP). https://hackage.haskell.org/package/reactive-banana.
[2]
Albert Benveniste, Timothy Bourke, Benoit Caillaud, Bruno Pagano, and Marc Pouzet. 2017. A Type-Based Analysis of Causality Loops in Hybrid Systems Modelers. Journal of Nonlinear Analysis Hybrid Systems (2017).
[3]
Dariusz Biernacki, Jean-Louis Colaco, Marc Pouzet, and Grégoire Hamon. 2008. Clock-Directed Modular Code Generation for Synchronous Data-flow Languages. In ACM International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES). Tucson, Arizona, 10.
[4]
Daniel Bünzli. [n. d.]. React, Functional Reactive Programming for OCaml. https://erratique.ch/talks/react-ocamlum-2010.pdf. Accessed: 2019-05-09.
[5]
Francois E. Cellier and Ernesto Kofman. 2006. Continuous System Simulation. Springer-Verlag, Berlin, Heidelberg.
[6]
Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. 2005. Associated Type Synonyms. In Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming (ICFP '05). ACM, New York, NY, USA, 241--253. https://doi.org/10.1145/1086365.1086397
[7]
Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. 2005. Associated Types with Class. In Proceedings of the 32Nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '05). ACM, New York, NY, USA, 1--13. https://doi.org/10.1145/1040305.1040306
[8]
Antony Courtney, Henrik Nilsson, and John Peterson. 2003. The Yampa Arcade. In Proceedings of the 2003 ACM SIGPLAN Workshop on Haskell (Haskell '03). ACM, Uppsala, Sweden, 7--18. https://doi.org/10.1145/871895.871897
[9]
Evan Czaplicki. 2012. Elm: Concurrent FRP for Functional GUIs. Undergraduate Thesis. Harward University.
[10]
Conal Elliott. 1996. A Brief Introduction to ActiveVRML. Technical Report MSR-TR-96-05. Microsoft Research.
[11]
Conal Elliott and Paul Hudak. 1997. Functional Reactive Animation. In International Conference on Functional Programming.
[12]
Conal M. Elliott. 2009. Push-Pull Functional Reactive Programming. In Proceedings of the 2nd ACM SIGPLAN Symposium on Haskell - Haskell '09. ACM Press, Edinburgh, Scotland, 25. https://doi.org/10.1145/1596638.1596643
[13]
FRP [n. d.]. Functional reactive programming. http://en.wikipedia.org/wiki/Functional_reactive_programming. Accessed: 2019-05-09.
[14]
George Giorgidze and Henrik Nilsson. 2008. Switched-On Yampa. In Practical Aspects of Declarative Languages, Paul Hudak and David S. Warren (Eds.). Vol. 4902. Springer Berlin Heidelberg, Berlin, Heidelberg, 282--298. https://doi.org/10.1007/978-3-540-77442-6_19
[15]
George Giorgidze and Henrik Nilsson. 2011. Embedding a Functional Hybrid Modelling Language in Haskell. In Implementation and Application of Functional Languages: 20th International Symposium, IFL 2008, Revised Selected Papers (Lecture Notes in Computer Science), Sven-Bodo Scholz and Olaf Chitil (Eds.), Vol. 5836. Springer-Verlag, 138--155. https://doi.org/978-3-642-24451-3
[16]
Paul Hudak, Antony Courtney, Henrik Nilsson, and John Peterson. 2003. Arrows, Robots, and Functional Reactive Programming. In Summer School on Advanced Functional Programming 2002, Oxford University (Lecture Notes in Computer Science), Vol. 2638. Springer-Verlag, 159--187.
[17]
John Hughes. 2000. Generalising Monads to Arrows. Science of computer programming 37, 1-3 (2000), 67--111.
[18]
Neelakantan R. Krishnaswami and Nick Benton. 2011. Ultrametric Semantics of Reactive Programs. In 2011 IEEE 26th Annual Symposium on Logic in Computer Science. IEEE, Toronto, ON, Canada, 257--266. https://doi.org/10.1109/LICS.2011.38
[19]
Jérôme Mahuet. 2015. Flappy Haskell. https://github.com/Rydgel/flappy-haskell.
[20]
Geoffrey Mainland. 2007. Why It's Nice to Be Quoted: Quasiquoting for Haskell. In Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop - Haskell '07. ACM Press, Freiburg, Germany, 73. https://doi.org/10.1145/1291201.1291211
[21]
Henrik Nilsson. 2005. Dynamic Optimization for Functional Reactive Programming Using Generalized Algebraic Data Types. In Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming (ICFP '05). ACM, New York, NY, USA, 54--65. https://doi.org/10.1145/1086365.1086374
[22]
Henrik Nilsson and Guerric Chupin. 2017. Funky Grooves: Declarative Programming of Full-Fledged Musical Applications. In 19th International Symposium on Practical Aspects of Declarative Languages (PADL 2017) (Lecture Notes in Computer Science), Yuliya Lierler and Walid Taha (Eds.), Vol. 10137. Springer, Paris, 163--172. https://doi.org/10.1007/978-3-319-51676-9_11
[23]
Henrik Nilsson, Antony Courtney, and John Peterson. 2002. Functional Reactive Programming, Continued. In Proceedings of the 2002 ACM SIGPLAN Haskell Workshop (Haskell'02). ACM, Pittsburgh, Pennsylvania, USA, 51--64.
[24]
Brian O'Sullivan. 2009. Criterion, a New Benchmarking Library for Haskell. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/.
[25]
Gergely Patai. [n. d.]. Eventless Reactivity from Scratch. ([n. d.]), 15.
[26]
Gergely Patai. 2011. Efficient and Compositional Higher-Order Streams. In Functional and Constraint Logic Programming, Julio Mariño (Ed.). Vol. 6559. Springer Berlin Heidelberg, Berlin, Heidelberg, 137--154. https://doi.org/10.1007/978-3-642-20775-4_8
[27]
Ross Paterson. 2001. A New Notation for Arrows. In International Conference on Functional Programming. ACM Press, Firenze, Italy, 229--240. http://www.soi.city.ac.uk/ross/papers/notation.html
[28]
Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Wash burn. 2006. Simple Unification-Based Type Inference for GADTs. In Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming (ICFP '06). ACM, New York, NY, USA, 50--61. https://doi.org/10.1145/1159803.1159811
[29]
ReactiveX [n. d.]. Reactive extensions. http://en.wikipedia.org/wiki/Reactive_ extensions. Accessed: 2019-05-09.
[30]
Neil Sculthorpe and Henrik Nilsson. 2011. Keeping Calm in the Face of Change: Towards Optimisation of FRP by Reasoning about Change. Journal of Higher-Order and Symbolic Computation 23, 2 (2011), 227--271. https://doi.org/10.1007/s10990-011-9068-x
[31]
D D Sleator, R E Tarjan, and W P Thurston. 1986. Rotation Distance, Triangulations, and Hyperbolic Geometry. In Proceedings of the Eighteenth Annual ACM Symposium on Theory of Computing (STOC '86). ACM, New York, NY, USA, 122--135. https://doi.org/10.1145/12130.12143
[32]
Ertugrul Söylemez. [n. d.]. Netwire: Library for Functional Reactive Programming (FRP). http://hackage.haskell.org/package/netwire. Accessed: 2019-05-09.
[33]
Ertugrul Söylemez. [n. d.]. Wires: Functional Reactive Programming Library. //hackage.haskell.org/package/wires. Accessed: 2019-05-09.
[34]
The GHC Team. [n.d.]. Glasgow Haskell Compiler User's Guide. https://downloads. haskell.org/~ghc/8.6.5/docs/html/users_guide/ Accessed: 2019-07-01.
[35]
Jonathan Thaler, Thorsten Altenkirch, and Peer-Olaf Siebers. 2018. Pure Functional Epidemics: An Agent-Based Approach. In IFL 2018: The 30th symposium on Implementation and Application of Functional Languages. ACM, 1--12.
[36]
Atze van der Ploeg and Koen Claessen. 2015. Practical Principled FRP: Forget the Past, Change the Future, FRPNow!. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP 2015). ACM, New York, NY, USA, 302--314. https://doi.org/10.1145/2784731.2784752
[37]
Zhanyong Wan and Paul Hudak. 2000. Functional Reactive Programming from First Principles. SIGPLAN Not. 35, 5 (May 2000), 242--252. https://doi.org/10.1145/358438.349331
[38]
Jeremy Yallop and Hai Liu. 2016. Causal Commutative Arrows Revisited. In Proceedings of the 9th International Symposium on Haskell (Haskell 2016). ACM, New York, NY, USA, 21--32. https://doi.org/10.1145/2976002.2976019
[39]
Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a Promotion. In Proceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation - TLDI '12. ACM Press, Philadelphia, Pennsylvania, USA, 53. https://doi.org/10.1145/2103786.2103795

Cited By

View all
  • (2024)Functional Reactive Programming, RearrangedProceedings of the 17th ACM SIGPLAN International Haskell Symposium10.1145/3677999.3678278(55-67)Online publication date: 29-Aug-2024
  • (2024)Cognitive Programming AssistantAdvances in Information and Communication10.1007/978-3-031-54053-0_1(1-11)Online publication date: 17-Mar-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
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Other conferences
PPDP '19: Proceedings of the 21st International Symposium on Principles and Practice of Declarative Programming
October 2019
280 pages
ISBN:9781450372497
DOI:10.1145/3354166
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 ACM 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]

In-Cooperation

  • Sony: Sony Corporation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 07 October 2019

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Research-article
  • Research
  • Refereed limited

Conference

PPDP '19

Acceptance Rates

PPDP '19 Paper Acceptance Rate 19 of 45 submissions, 42%;
Overall Acceptance Rate 230 of 486 submissions, 47%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)43
  • Downloads (Last 6 weeks)9
Reflects downloads up to 07 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Functional Reactive Programming, RearrangedProceedings of the 17th ACM SIGPLAN International Haskell Symposium10.1145/3677999.3678278(55-67)Online publication date: 29-Aug-2024
  • (2024)Cognitive Programming AssistantAdvances in Information and Communication10.1007/978-3-031-54053-0_1(1-11)Online publication date: 17-Mar-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
  • (2023)FACT: A Domain-Specific Language Based on a Functional Algebra for Continuous Time Modeling2023 Winter Simulation Conference (WSC)10.1109/WSC60868.2023.10408703(2650-2661)Online publication date: 10-Dec-2023
  • (2023)Virtual Machines and Hypergraph Data/Code Models: Graph-Theoretic Representations of Lambda-Style CalculiAI, IoT, Big Data and Cloud Computing for Industry 4.010.1007/978-3-031-29713-7_21(387-429)Online publication date: 30-Mar-2023
  • (2022)A Graph-Based Formal Semantics of Reactive Programming from First PrinciplesProceedings of the 24th ACM International Workshop on Formal Techniques for Java-like Programs10.1145/3611096.3611101(18-25)Online publication date: 7-Jun-2022
  • (2022)Using Functional Reactive Programming to Define Safe Actor SystemsProceedings of the 24th ACM International Workshop on Formal Techniques for Java-like Programs10.1145/3611096.3611098(4-10)Online publication date: 7-Jun-2022
  • (2022)Semantics of RxJSProceedings of the 9th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems10.1145/3563837.3568340(37-49)Online publication date: 29-Nov-2022
  • (2021)Modular Compilation for a Hybrid Non-Causal Modelling LanguageElectronics10.3390/electronics1007081410:7(814)Online publication date: 30-Mar-2021
  • (2021)Trampoline variables: a general method for state accumulation in reactive programmingProceedings of the 8th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems10.1145/3486605.3486787(27-40)Online publication date: 18-Oct-2021
  • Show More Cited By

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