The Calculated Typer (Functional Pearl)

Authors:
Zac Garby, Patrick Bahr, Graham Hutton
Published:
In Haskell '25: 18th ACM SIGPLAN International Haskell Symposium. October 9, 2025.
Abstract:

We present a calculational approach to the design of type checkers, showing how they can be derived from behavioural specifications using equational reasoning. We focus on languages whose semantics can be expressed as a fold, and show how the calculations can be simplified using fold fusion. This approach enables the compositional derivation of correct-by-construction type checkers based on solving and composing fusion preconditions. We introduce our approach using a simple expression language, to which we then add support for exception handling and checked exceptions.

BibTeX:
@inproceedings{garby2025,
  title = {{The Calculated Typer (Functional Pearl)}},
  author = {Zac Garby and Patrick Bahr and Graham Hutton},
  booktitle = {Haskell '25: 18th ACM SIGPLAN International Haskell Symposium},
  year = 2025,
  doi = {10.1145/3759164.3759346},
}