Functional reactive programming with liveness guarantees

Functional Reactive Programming (FRP) is an approach to the development of reactive systems which provides a pure functional interface, but which may be implemented as an abstraction of an imperative event-driven layer. FRP systems typically provide a model of behaviours (total time-indexed values, implemented as pull systems) and event sources (partial time-indexed values, implemented as push systems). In this paper, we investigate a type system for event-driven FRP programs which provide liveness guarantees, that is every input event is guaranteed to generate an output event. We show that FRP can be implemented on top of a model of sets and relations, and that the isomorphism between event sources and behaviours corresponds to the isomorphism between relations and set-valued functions. We then implement sets and relations using a model of continuations using the usual double-negation CPS transform. The implementation of behaviours as pull systems based on futures, and of event sources as push systems based on the observer pattern, thus arises from first principles. We also discuss a Java implementation of the FRP model.

[1]  Wolfgang Jeltsch Signals, Not Generators! , 2009, Trends in Functional Programming.

[2]  Gérard Berry,et al.  The Esterel Synchronous Programming Language: Design, Semantics, Implementation , 1992, Sci. Comput. Program..

[3]  Daan Leijen,et al.  Domain specific embedded compilers , 1999, DSL '99.

[4]  Henrik Nilsson,et al.  Functional reactive programming, continued , 2002, Haskell '02.

[5]  Paul Hudak,et al.  Functional reactive animation , 1997, ICFP '97.

[6]  Wolfgang Jeltsch Strongly typed and efficient functional reactive programming , 2011 .

[7]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[8]  Guy L. Steele,et al.  Java(TM) Language Specification, The (3rd Edition) (Java (Addison-Wesley)) , 2005 .

[9]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[10]  Stephen L. Burbeck,et al.  Applications programming in smalltalk-80: how to use model-view-controller (mvc) , 1987 .

[11]  Shriram Krishnamurthi,et al.  Embedding Dynamic Dataflow in a Call-by-Value Language , 2006, ESOP.

[12]  Alan Jeffrey,et al.  Causality for free!: parametricity implies causality for functional reactive programs , 2013, PLPV.

[13]  Conal Elliott,et al.  Push-pull functional reactive programming , 2009, Haskell.

[14]  Carl Hewitt,et al.  A Universal Modular ACTOR Formalism for Artificial Intelligence , 1973, IJCAI.

[15]  Shriram Krishnamurthi,et al.  Flapjax: a programming language for Ajax applications , 2009, OOPSLA '09.

[16]  Robert Harper,et al.  Self-adjusting computation , 2004, Proceedings of the 19th Annual IEEE Symposium on Logic in Computer Science, 2004..

[17]  Alan Jeffrey,et al.  Dependently Typed Web Client Applications - FRP in Agda in HTML5 , 2013, PADL.

[18]  Robert Harper Self-adjusting computation , 2004, LICS 2004.

[19]  Nick Benton,et al.  Ultrametric Semantics of Reactive Programs , 2011, 2011 IEEE 26th Annual Symposium on Logic in Computer Science.

[20]  Antony Courtney,et al.  Frappé: Functional Reactive Programming in Java , 2001, PADL.