Skip to main content

Research Repository

Advanced Search

Monadic Compiler Calculation (Functional Pearl)

Hutton, Graham; Bahr, Patrick


Patrick Bahr


Bahr and Hutton recently developed a new approach to calculating correct compilers directly from specifications of their correctness. However, the methodology only considers converging behaviour of the source language, which means that the compiler could potentially produce arbitrary, erroneous code for source programs that diverge. In this article, we show how the methodology can naturally be extended to support the calculation of compilers that address both convergent and divergent behaviour simultaneously, without the need for separate reasoning for each aspect. Our approach is based on the use of the partiality monad to make divergence explicit, together with the use of strong bisimilarity to support equational-style calculations, but also generalises to other forms of effect by changing the underlying monad.


Hutton, G., & Bahr, P. (2022). Monadic Compiler Calculation (Functional Pearl). Proceedings of the ACM on Programming Languages, 6(ICFP), 1-27.

Journal Article Type Article
Acceptance Date Jul 1, 2022
Online Publication Date Aug 31, 2022
Publication Date Aug 31, 2022
Deposit Date Jul 21, 2022
Publicly Available Date Jul 29, 2022
Journal Proceedings of the ACM on Programming Languages
Publisher Association for Computing Machinery (ACM)
Peer Reviewed Peer Reviewed
Volume 6
Issue ICFP
Article Number 93
Pages 1-27
Public URL
Publisher URL


You might also like

Downloadable Citations