skip to main content
research-article

Monadic functional reactive programming

Published:23 September 2013Publication History
Skip Abstract Section

Abstract

Functional Reactive Programming (FRP) is a way to program reactive systems in functional style, eliminating many of the problems that arise from imperative techniques. In this paper, we present an alternative FRP formulation that is based on the notion of a reactive computation: a monadic computation which may require the occurrence of external events to continue. A signal computation is a reactive computation that may also emit values. In contrast to signals in other FRP formulations, signal computations can end, leading to a monadic interface for sequencing signal phases. This interface has several advantages: routing is implicit, sequencing signal phases is easier and more intuitive than when using the switching combinators found in other FRP approaches, and dynamic lists require much less boilerplate code. In other FRP approaches, either the entire FRP expression is re-evaluated on each external stimulus, or impure techniques are used to prevent redundant re-computations. We show how Monadic FRP can be implemented straightforwardly in a purely functional way while preventing redundant re-computations.

References

  1. G. H. Cooper and S. Krishnamurthi. Embedding dynamic dataflow in a call-by-value language. In Proc. of the '06 European Symposium on Programming, pages 294--308, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. Courtney. Frappé: Functional reactive programming in Java. In Proc. of the '01 International Symposium of Pratical Aspects of Declarative Languages, March 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. Courtney and C. Elliott. Genuinely functional user interfaces. In Proc. of the '01 Haskell Workshop, September 2001.Google ScholarGoogle Scholar
  4. A. Courtney, H. Nilsson, and J. Peterson. The Yampa arcade. In Proc. of the '03 Haskell Workshop, pages 7--18, Aug. 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. C. Elliott. Functional implementations of continuous modeled animation. In Proc. of the 10th International Symposium on Principles of Declarative Programming, pages 284--299, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. Elliott. Push-pull functional reactive programming. In Proc. of the '09 Haskell Symposium, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. Elliott and P. Hudak. Functional reactive animation. In Proc. of the 1997 International Conference on Functional Programming, ICFP '1997, pages 163--173, June 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. P. Hudak, A. Courtney, H. Nilsson, and J. Peterson. Arrows, robots, and functional reactive programming. In '02 Summer School on Advanced Functional Programming, pages 159--187, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  9. J. Hughes. Generalising monads to arrows. Science of Computer Programming, 37(1-3):67--111, May 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. S. A. Jeffrey. Causality for free!: Parametricity implies causality for functional reactive programs. In Programming Languages meets Program Verification, PLPV '13, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. P. Klint and A. van der Ploeg. A library for declarative resolution- independent 2d graphics. In Proc. of the '13 International Symposium on Practical Aspects of Declarative Languages, PADL '13, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. I. Maier and M. Odersky. Deprecating the Observer Pattern with Scala.react. Technical report, LAMP, 2012.Google ScholarGoogle Scholar
  13. C. Mcbride and R. Paterson. Applicative programming with effects. Journal of Functional Programming, 18(1):1--13, Jan. 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. L. A. Meyerovich, A. Guha, J. Baskin, G. H. Cooper, M. Greenberg, A. Bromfield, and S. Krishnamurthi. Flapjax: a programming language for Ajax applications. In Proc. of the '09 Conference on Object oriented programming systems languages and applications, pages 1--20, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. H. Nilsson, A. Courtney, and J. Peterson. Functional reactive programming, continued. In Proc. of the '02 Haskell Workshop, pages 51--64, Oct. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. Paterson. A new notation for arrows. In Proceedings of the '01 international conference on Functional programming, pages 229--240, 2001. ISBN 1-58113-415-0. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Peterson, G. Hager, and P. Hudak. A language for declarative robotic programming. In Proc. of the 1999 International Conference on Robotics and Automation, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  18. J. Peterson, P. Hudak, and C. Elliott. Lambda in Motion: Controlling robots with Haskell. In Proc. of the 1th International Workshop on Practical Aspects of Declarative Languages, PADL 1999, January 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. J. Peterson, P. Hudak, A. Reid, and G. Hager. FVision: A declarative language for visual tracking. In Proc. of the '01 International Workshop on Practical Aspects of Declarative Languages, PADL '01, pages 304--321, Jan. 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. N. Sculthorpe and H. Nilsson. Safe functional reactive programming through dependent types. In Proc. of the '09 International conference on Functional programming, ICFP '09, pages 23--34, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Monadic functional reactive programming

    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

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 48, Issue 12
      Haskell '13
      December 2013
      149 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2578854
      Issue’s Table of Contents
      • cover image ACM Conferences
        Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on Haskell
        September 2013
        158 pages
        ISBN:9781450323833
        DOI:10.1145/2503778

      Copyright © 2013 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 23 September 2013

      Check for updates

      Qualifiers

      • research-article

    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!