February 2017

A shorter version of this paper was submitted for publication to ICFP 2017


It is well-known that the simply typed lambda-calculus is modeled by any cartesian closed category (CCC). This correspondence suggests giving typed functional programs a variety of interpretations, each corresponding to a different category. A convenient way to realize this idea is as a collection of meaning-preserving transformations added to an existing compiler, such as GHC for Haskell. This paper describes such an implementation and demonstrates its use for a variety of interpretations including hardware circuits, automatic differentiation, incremental computation, and interval analysis. Each such interpretation is a category easily defined in Haskell (outside of the compiler). The general technique appears to provide a compelling alternative to deeply embedded domain-specific languages.

Paper (700K PDF, 2017/02/27, minor revisions 2017/03/29)


  author = {Conal Elliott},
  title = {Compiling to categories},
  note = {A shorter version was submitted for publication to ICFP 2017},
  month = feb,
  year = 2017,
  url = {http://conal.net/papers/compiling-to-categories}