Wormholes: introducing effects to FRP

Functional reactive programming (FRP) is a useful model for programming real-time and reactive systems in which one defines a signal function to process a stream of input values into a stream of output values. However, performing side effects (e.g. memory mutation or input/output) in this model is tricky and typically unsafe. In previous work, Winograd-Cort et al. [2012] introduced resource types and wormholes to address this problem. This paper better motivates, expands upon, and formalizes the notion of a wormhole to fully unlock its potential. We show, for example, that wormholes can be used to define the concept of causality. This in turn allows us to provide behaviors such as looping, a core component of most languages, without building it directly into the language. We also improve upon our previous design by making wormholes less verbose and easier to use. To formalize the notion of a wormhole, we define an extension to the simply typed lambda calculus, complete with typing rules and operational semantics. In addition, we present a new form of semantic transition that we call a temporal transition to specify how an FRP program behaves over time and to allow us to better reason about causality. As our model is designed for a Haskell implementation, the semantics are lazy. Finally, with the language defined, we prove that our wormholes indeed allow side effects to be performed safely in an FRP framework.

[1]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[2]  Paul Hudak,et al.  Arrows, Robots, and Functional Reactive Programming , 2002, Advanced Functional Programming.

[3]  Wolfgang Jeltsch,et al.  Towards a Common Categorical Semantics for Linear-Time Temporal Logic and Functional Reactive Programming , 2012, MFPS.

[4]  Paul Hudak The Haskell School of Expression: Learning Functional Programming through Multimedia , 1999 .

[5]  Simon L. Peyton Jones,et al.  Giving Haskell a promotion , 2012, TLDI '12.

[6]  Ricky Yeung,et al.  TBAG: a high level framework for interactive, animated 3D graphics applications , 1994, SIGGRAPH.

[7]  Alan Jeffrey,et al.  LTL types FRP: linear-time temporal logic propositions as types, proofs as functional reactive programs , 2012, PLPV '12.

[8]  Nicolas Halbwachs,et al.  LUSTRE: A declarative language for programming synchronous systems* , 1987 .

[9]  Paul Le Guernic,et al.  SIGNAL: A declarative language for synchronous programming of real-time systems , 1987, FPCA.

[10]  Eugenio Moggi,et al.  Computational lambda-calculus and monads , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[11]  Marko C. J. D. van Eekelen,et al.  CLEAN: A language for functional graph writing , 1987, FPCA.

[12]  Patrick Lincoln,et al.  Linear logic , 1992, SIGA.

[13]  Ross Paterson,et al.  A new notation for arrows , 2001, ICFP '01.

[14]  Nick Benton,et al.  Higher-order functional reactive programming in bounded space , 2012, POPL '12.

[15]  Philip Wadler,et al.  Is there a use for linear logic? , 1991, PEPM '91.

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

[17]  Riccardo Pucella,et al.  Practical affine types , 2011, POPL '11.

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

[19]  P. Hudak,et al.  Causal commutative arrows , 2011, Journal of Functional Programming.

[20]  Henrik Nilsson,et al.  The Yampa arcade , 2003, Haskell '03.

[21]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[22]  Gérard Berry,et al.  The ESTEREL Synchronous Programming Language and its Mathematical Semantics , 1984, Seminar on Concurrency.

[23]  John Hughes,et al.  Generalising monads to arrows , 2000, Sci. Comput. Program..

[24]  Gregory H. Cooper,et al.  Integrating Dataflow Evaluation into a Practical Higher-Order Call-by-Value Language , 2008 .

[25]  Paul Hudak,et al.  Plugging a Space Leak with an Arrow , 2007, Festschrift honoring Gary Lindstrom.

[26]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[27]  Paul Hudak,et al.  Virtualizing Real-World Objects in FRP , 2012, PADL.

[28]  Paul Hudak,et al.  Nettle: Taking the Sting Out of Programming Network Routers , 2011, PADL.

[29]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.

[30]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[31]  WadlerPhilip Is there a use for linear logic , 1991 .

[32]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[33]  C. Hawblitzel Linear Types for Aliased Resources (Extended Version) , 2005 .

[34]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[35]  Philip Wadler,et al.  The arrow calculus , 2010, J. Funct. Program..