Functional EDSLs for Web Applications

Sammanfattning: This thesis aims to make the development of complex web applications easier, faster and safer through the application of strongly typed functional programming techniques. Traditional web applications are commonly written in the de facto standard language of the web, JavaScript, which, being untyped, provides no guarantees regarding the data processed by programs, increasing the burden of testing and defensive programming. Modern web applications are often highly complex, with multiple interdependent parts interacting over the Internet. Such applications are traditionally implemented with each component as a separate program, exposing its functionality to other components through different API:s over some communication protocol such as HTTP. This process is mostly manual, and thus error-prone and labour intensive, with accidental API incompatibility between components being particularly problematic. Even in a conventional typed language, the absence of such incompatibilities is not guaranteed. While the different components may well be type-safe in isolation, there is no guarantee that the whole is type-safe as the communication between components is not type-checked. We present a web application development framework, based on the Haskell programming language, to increase programmer productivity and software quality by addressing these issues. In our framework, applications with an arbitrary number of components are written, compiled and type-checked as a single program, guaranteeing that the application as a whole, including network communication, is type-safe. Communication between components is automatically generated by our framework, eliminating the risk of API incompatibilities completely. Additionally, our framework includes a state-of-the-art compiler from Haskell to JavaScript, a novel, lightweight foreign function interface to allow programs to leverage existing JavaScript code, an embedded language for integrating low-level, high-performance kernels into otherwise high-level web applications, as well as a highly expressive relational database language.