Functional programming languages are well-suited for developing compilers, and compilers for functional languages are often themselves written in a functional language. Functional abstractions, such as monads, allow abstracting away some of the repetitive structure of a compiler, removing boilerplate code and making extensions simpler. Even so,functional languages are rarely used to implement compilers for languages of other paradigms. This paper reports on the experience of a four-year long project where we developed a compiler for a concurrent, object-oriented language using the functional language Haskell.The focus of the paper is the implementation of the typechecker, but the design works well in static analysis tools, such as tracking uniqueness of variables to ensure data-race freedom. The paper starts from a simple type checker to which we add more complex features, such as type state, with minimal changes to the overall initial design.
Dr Kiko Fernandez-Reyes
Software Engineer at Klarna. Previously, I was part of the programming languages research group at Uppsala University with specialisation in concurrent and functional programming languages, type systems, and formal methods, core developer of the actor-based Encore programming language, and main lecturer of the course Advanced Software Design at Uppsala University.