kirancodes.me
To Proof Maintenance & Beyond!

A typechecker plugin for units of measure: domain-specific constraint solving in GHC Haskell

Adam Gundry

Abstract

Typed functional programming and units of measure are a natural combination, as F# ably demonstrates. However, encoding statically-checked units in Haskell’s type system leads to inevitable disappointment with the usability of the resulting system. Extending the language itself would produce a much better result, but it would be a lot of work! In this paper, I demonstrate how typechecker plugins in the Glasgow Haskell Compiler allow users to define domain-specific constraint solving behaviour, making it possible to implement units of measure as a type system extension without rebuilding the compiler. This paves the way for a more modular treatment of constraint solving in GHC.

DOI 10.1145/2804302.2804305

Related papers