Skip to content
← Back to projects

CS4201 P2

A compiler from a custom functional language to Java

LANGUAGES

COURSEWORK

HASKELL

JAVA

November 2024

Source: https://github.com/lixitrixi/cs4201-p2

Report: https://www.overleaf.com/read/nbjrzhgpqytb#925f96

As part of the CS4201 module on Programming Language Design and Implementation, this project focused on the backend stages of a compiler for a functional language called Defun, translating it into Java. The assignment explored key concepts in programming language theory, including defunctionalisation, administrative normal form (ANF) conversion, and target code generation—all central to the study of intermediate representations in compilers.

This project provided a valuable opportunity to deepen my understanding of functional programming semantics, compiler pipeline design, and practical code transformation techniques. Throughout the coursework, I implemented a multi-stage compiler, introduced a testing suite, and extended the original specification with support for boolean logic, displaying custom objects, and safer variable scoping.

In addition to meeting the core requirements, I also explored edge cases in variable naming, function application, and pattern matching. The experience sharpened my skills in Haskell, reinforced principles of code generation and type theory, and offered firsthand insight into compiler behavior beyond textbook examples.

A full report is available here.

Felix Leitner • Source