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.