Structuring Domain-Specific Languages with Effects
Author:
Abstract:
Domain specific languages (DSL) are abundant in software development. They are languages with a constrained feature set aiming to improve the productivity of a programmer creating programs for a particular domain. Since they are tailored to a specific domain, domain experts have an easier time reading and writing programs in such a DSL as well. Even though the practice of creating DSLs is widely used, there is still a lot of room for improvement. In this thesis we study the use of internal DSLs in Haskell. These are DSLs which are built within Haskell and are able to use the variety of tools that Haskell provides, such as its syntax and typechecker. We investigate different aspects of DSLs with the help of three case studies: stream processing, animations and build systems. For the stream processing DSL, we mainly investigate the performance aspect. In particular, we reconstruct the three-continuation representation, a recently presented alternative representation, in a more approachable manner. We investigate its performance properties in detail and improve upon the original implementation by employing techniques such as fusion and inlining, which are found in other Haskell stream processing libraries. The animation DSL presents a new approach to representing animations in a composable manner. We implement the DSL using the mtl style to achieve modularity, which enables it to be composed with other DSLs developed in the same style. In addition to this, we investigate the impact of the inspectability requirement, in particular with respect to the expressivity of the DSL. The build system DSL is based on earlier work which models build systems in a functional manner. We employ it as a case study to illustrate an extension to the underlying theory of algebraic effects and handlers, an alternative to mtl style to support inspectability. This extension moves the foundation of free algebras to that of free generalized monoids.