Reactive Objects and Functional Programming

The construction of robust distributed and interactive software is still a challenging task, despite the recent popularity-increase for languages that take advanced programming concepts into the mainstream. Several problematic areas can be identified: most languages require the reactivity of a system to be manually upheld by careful avoidance of blocking operations; mathematical values often need to be encoded in terms of stateful objects or vice versa; concurrency is particularly tricky in conjunction with encapsulated software components; and static type safety is often compromised because of the lack of simultaneous support for both subtyping and polymorphism . This thesis presents a programming language, O'Haskell , that has been consciously designed with these considerations in mind. O'Haskell is defined by conservatively extending the purely functional language Haskell with the following features: A central structuring mechanism based on reactive objects , which unify the notions of objects and concurrent processes. Reactive objects are asynchronous, state-encapsulating servers whose purpose is to react to input messages; they cannot actively block execution or selectively filter their sources of input. A monadic layer of object-based computational effects, which clearly separates stateful objects from stateless values. Apart from higher-order functions and recursive data structures, the latter notion also includes first-class commands, object templates, and methods. A safe, polymorphic type system with declared record and datatype subtyping, supported by a powerful partial type inference algorithm. It is claimed that these features make O'Haskell especially well-adapted for the task of modern software construction. The thesis presents O'Haskell from both a practical and a theoretical perspective. The practical contributions are a full implementation of the language, a number of non-trivial programming examples that illustrate the merits of reactive objects in a realistic context, and several reusable programming methods for such applications as graphical user interfaces, embedded controllers, and network protocols. The theoretical results serve to substantiate the informal claim made regarding usability, and include a provably sound polymorphic subtyping system, soundness and partial completeness for the inference algorithm, a formal dynamic semantics, and a result that characterizes the conservative extension of a purely functional language with state and concurrency.

[1]  Amos Israeli,et al.  Self-Stabilization of Dynamic Systems Assuming only Read/Write Atomicity , 1990, PODC.

[2]  Kalevi Hyyppä Optical Navigation System Using Passive, Identical Beacons , 1986, IAS.

[3]  David Turner,et al.  Functional Programming and Communicating Processes , 1987, PARLE.

[4]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[5]  F. Warren Burton Nondeterminism with Referential Transparency in Functional Programming Languages , 1988, Comput. J..

[6]  John Hughes,et al.  Why Functional Programming Matters , 1989, Comput. J..

[7]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[8]  Jim Waldo,et al.  A Note on Distributed Computing , 1996, Mobile Object Systems.

[9]  William R. Cook,et al.  Object-Oriented Programming Versus Abstract Data Types , 1990, REX Workshop.

[10]  Robin Milner,et al.  Definition of standard ML , 1990 .

[11]  Mark P. Jones A system of constructor classes: overloading and implicit higher-order polymorphism , 1993, FPCA '93.

[12]  Anand R. Tripathi,et al.  Communication, scheduling, and resource management in SINA , 1988 .

[13]  Mark P. Jones,et al.  First-class polymorphism with type inference , 1997, POPL '97.

[14]  Benjamin C. Pierce,et al.  Higher-Order Subtyping , 1994, Theor. Comput. Sci..

[15]  Alexander Aiken,et al.  Type inclusion constraints and type inference , 1993, FPCA '93.

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

[17]  Simon L. Peyton Jones,et al.  Concurrent Haskell , 1996, POPL '96.

[18]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[19]  Prateek Mishra,et al.  Type Inference with Subtypes , 1990, Theor. Comput. Sci..

[20]  Stefan Kaes Type inference in the presence of overloading, subtyping and recursive types , 1992, LFP '92.

[21]  John W. Lloyd,et al.  Declarative Programming in Escher , 1995 .

[22]  John C. Mitchell,et al.  Lower bounds on type inference with subtypes , 1995, POPL '95.

[23]  John K. Ousterhout,et al.  Tcl and the Tk Toolkit , 1994 .

[24]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[25]  John W. Backus,et al.  Can programming be liberated from the von Neumann style?: a functional style and its algebra of programs , 1978, CACM.

[26]  Carolyn L. Talcott,et al.  A foundation for actor computation , 1997, Journal of Functional Programming.

[27]  Gul A. Agha,et al.  ACTORS - a model of concurrent computation in distributed systems , 1985, MIT Press series in artificial intelligence.

[28]  Roy H. Campbell,et al.  The specification of process synchronization by path expressions , 1974, Symposium on Operating Systems.

[29]  Radha Jagadeesan,et al.  Design and implementation of Triveni: a process-algebraic API for threads + events , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).

[30]  Frédéric Boussinot,et al.  The SugarCubes tool box: a reactive Java framework , 1998 .

[31]  Philip Wadler,et al.  How to declare an imperative , 1997, CSUR.

[32]  Jan K. Pachl,et al.  Uniform self-stabilizing rings , 1988, TOPL.

[33]  Simon L. Peyton Jones,et al.  Compiling Haskell by Program Transformation: A Report from the Trenches , 1996, ESOP.

[34]  Philip Wadler,et al.  The essence of functional programming (Invited talk) , 1997 .

[35]  Michael Papathomas,et al.  Language Design Rationale and Semantic Framework for Concurrent Object-Oriented Programming , 1992 .

[36]  John C. Mitchell,et al.  Coercion and type inference , 1984, POPL.

[37]  Scott F. Smith,et al.  Sound polymorphic type inference for objects , 1995, OOPSLA.

[38]  Simon L. Peyton Jones,et al.  The Implementation of Functional Programming Languages , 1987 .

[39]  C. A. R. Hoare,et al.  Monitors: an operating system structuring concept , 1974, CACM.

[40]  Alan Snyder Encapsulation and inheritance in object-oriented programming languages , 1986, OOPSLA 1986.

[41]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[42]  Peter Henderson,et al.  Purely Functional Operating Systems , 1982 .

[43]  Simon Peyton Jones,et al.  Programming Reactive Systems in Haskell , 1994, Functional Programming.

[44]  Gérard Berry,et al.  The chemical abstract machine , 1989, POPL '90.

[45]  Radha Jagadeesan,et al.  Objects and Concurrency in Triveni: A Telecommunication Case Study in Java , 1998, COOTS.

[46]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[47]  Mohamed G. Gouda,et al.  Stabilizing Communication Protocols , 1991, IEEE Trans. Computers.

[48]  Albert Benveniste,et al.  The synchronous approach to reactive and real-time systems , 1991 .

[49]  John C. Mitchell,et al.  Type inference with simple subtypes , 1991, Journal of Functional Programming.

[50]  Prateek Mishra,et al.  Polymorphic Subtype Inference: Closing the Theory-Practice Gap , 1989, TAPSOFT, Vol.2.

[51]  Peter Buneman,et al.  Theoretical Aspects of Object-Oriented Programming , 1994 .

[52]  Luca Cardelli An implementation of F , 1993 .

[53]  Martin Odersky,et al.  Polymorphic type inference and abstract data types , 1994, TOPL.

[54]  Andrew Moran,et al.  Call-by-name, Call-by-need, and McCarthy's Amb , 1998 .

[55]  Philip Wadler,et al.  A practical subtyping system for Erlang , 1997, ICFP '97.

[56]  D. A. Turner The semantic elegance of applicative languages , 1981, FPCA '81.

[57]  Geoffrey Smith,et al.  Principal Type Schemes for Functional Programs with Overloading and Subtyping , 1994, Sci. Comput. Program..

[58]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[59]  Boaz Patt-Shamir,et al.  Self-stabilization by local checking and correction , 1991, [1991] Proceedings 32nd Annual Symposium of Foundations of Computer Science.

[60]  Pierre America,et al.  Inheritance and Subtyping in a Parallel Object-Oriented Language , 1987, ECOOP.

[61]  Lennart Augustsson,et al.  Cayenne—a language with dependent types , 1998, ICFP '98.

[62]  John C. Mitchell,et al.  Type Inference with Extended Pattern Matching and Subtypes , 1993, Fundamenta Informaticae.

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

[64]  Amos Israeli,et al.  Self-stabilization of dynamic systems assuming only read/write atomicity , 1990, PODC '90.

[65]  Oscar Nierstrasz Active objects in hybrid , 1987, OOPSLA 1987.

[66]  Daniel Leivant,et al.  Polymorphic type inference , 1983, POPL '83.

[67]  Joe Armstrong,et al.  Concurrent programming in ERLANG , 1993 .

[68]  Bruce J. MacLennan Values and objects in programming languages , 1982, SIGP.

[69]  Mats Carlsson,et al.  FUDGETS: a graphical user interface in a lazy functional language , 1993, FPCA '93.

[70]  Mark P. Jones,et al.  The implementation of the Gofer functional programming system , 1994 .

[71]  William Stoye Message-Based Functional Operating Systems , 1986, Sci. Comput. Program..

[72]  Anish Arora,et al.  Distributed Reset , 1994, IEEE Trans. Computers.

[73]  Amos Israeli,et al.  Self-Stabilizing Ring Orientation , 1990, WDAG.

[74]  Martin Odersky,et al.  Pizza into Java: translating theory into practice , 1997, POPL '97.

[75]  Johan Nordlander,et al.  Pragmatic subtyping in polymorphic languages , 1998, ICFP '98.

[76]  Mark P. Jones,et al.  Using parameterized signatures to express modular structure , 1996, POPL '96.

[77]  Peter Achten,et al.  Interactive functional programs: models, methods, and implementation , 1996 .

[78]  Andrew P. Black,et al.  Emerald: A general‐purpose programming language , 1990, Softw. Pract. Exp..

[79]  Andrzej Filinski,et al.  Representing monads , 1994, POPL '94.

[80]  Magnus Carlsson,et al.  Reactive objects in a functional language : an escape from the Evil I , 1997, ICFP 1997.

[81]  François Pottier,et al.  A framework for type inference with subtyping , 1998, ICFP '98.

[82]  Edsger W. Dijkstra,et al.  The structure of the “THE”-multiprogramming system , 1968, CACM.

[83]  Magnus Carlsson,et al.  Programming with Fudgets , 1995, Advanced Functional Programming.

[84]  Edsger W. Dijkstra,et al.  Self-stabilizing systems in spite of distributed control , 1974, CACM.

[85]  Nancy A. Lynch,et al.  An introduction to input/output automata , 1989 .

[86]  Bjarne Stroustrup,et al.  Multiple Inheritance for C++ , 1989, Comput. Syst..

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

[88]  Koen Claessen,et al.  Structuring graphical paradigms in TkGofer , 1997, ICFP '97.

[89]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[90]  Luca Cardelli,et al.  On Binary Methods , 1995, Theory Pract. Object Syst..

[91]  Stephan Merz,et al.  Type checking higher-order polymorphic multi-methods , 1997, POPL '97.

[92]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[93]  Didier Rémy,et al.  Objective ML: a simple object-oriented extension of ML , 1997, POPL '97.

[94]  Simon L. Peyton Jones,et al.  State in Haskell , 1995, LISP Symb. Comput..

[95]  Peter Wegner,et al.  Interactive Software Technology , 1997, The Computer Science and Engineering Handbook.

[96]  Simon L. Peyton Jones,et al.  A semantics for imprecise exceptions , 1999, PLDI '99.

[97]  Alan Jeffrey,et al.  A fully abstract semantics for a concurrent functional language with monadic types , 1995, Proceedings of Tenth Annual IEEE Symposium on Logic in Computer Science.

[98]  Jakob Rehof Minimal typings in atomic subtyping , 1997, POPL '97.

[99]  John H. Reppy Concurrent ML: Design, Application and Semantics , 1993, Functional Programming, Concurrency, Simulation and Automated Reasoning.

[100]  Simon L. Peyton Jones,et al.  Type Classes in Haskell , 1994, ESOP.

[101]  Benjamin C. Pierce,et al.  Concurrent Objects in a Process Calculus , 1994, Theory and Practice of Parallel Programming.

[102]  Riccardo Pucella,et al.  Reactive programming in Standard ML , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).

[103]  William E. Lorensen,et al.  Object-Oriented Modeling and Design , 1991, TOOLS.

[104]  François Pottier,et al.  Simplifying subtyping constraints , 1996, ICFP '96.

[105]  Enno Scholz,et al.  Imperative streams—a monadic combinator library for synchronous programming , 1998, ICFP '98.

[106]  Mario Tokoro,et al.  Experience and evolution of concurrent Smalltalk , 1987, OOPSLA 1987.

[107]  Benjamin C. Pierce,et al.  Pict: a programming language based on the Pi-Calculus , 2000, Proof, Language, and Interaction.

[108]  Shmuel Katz,et al.  Self-stabilizing extensions for meassage-passing systems , 2005, Distributed Computing.

[109]  Scott F. Smith,et al.  Subtyping Constrained Types , 1996, SAS.

[110]  Satoshi Matsuoka,et al.  Analysis of inheritance anomaly in object-oriented concurrent programming languages , 1993 .

[111]  John H. Reppy,et al.  Simple objects for Standard ML , 1996, PLDI '96.