A type-preserving compiler in Haskell

There has been a lot of interest of late for programming languages that incorporate features from dependent type systems and proof assistants, in order to capture important invariants of the program in the types. This allows type-based program verification and is a promising compromise between plain old types and full blown Hoare logic proofs. The introduction of GADTs in GHC (and more recently type families) made such dependent typing available in an industry-quality implementation, making it possible to consider its use in large scale programs. We have undertaken the construction of a complete compiler for System F, whose main property is that the GHC type checker verifies mechanically that each phase of the compiler properly preserves types. Our particular focus is on "types rather than proofs": reasonably few annotations that do not overwhelm the actual code. We believe it should be possible to write such a type-preserving compiler with an amount of extra code comparable to what is necessary for typical typed intermediate languages, but with the advantage of static checking. We will show in this paper the remaining hurdles to reach this goal.

[1]  Stefan Monnier,et al.  One Vote for Type Families in Haskell! , 2008, Trends in Functional Programming.

[2]  François Pottier,et al.  Polymorphic typed defunctionalization , 2004, POPL.

[3]  Zhong Shao,et al.  A Syntactic Approach to Foundational Proof-Carrying Code , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[4]  Robert Harper,et al.  Typed closure conversion , 1996, POPL '96.

[5]  Adam Chlipala,et al.  A certified type-preserving compiler from lambda calculus to assembly language , 2007, PLDI '07.

[6]  Robert Harper,et al.  TIL: a type-directed optimizing compiler for ML , 1996, PLDI '96.

[7]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[8]  Emir Pasalic,et al.  The role of type equality in meta-programming , 2004 .

[9]  Brigitte Pientka Functional Programming With Higher-order Abstract Syntax and Explicit Substitutions , 2007, Electron. Notes Theor. Comput. Sci..

[10]  Karl Crary,et al.  From system F to typed assembly language , 1999 .

[11]  Adam Chlipala Parametric higher-order abstract syntax for mechanized semantics , 2008, ICFP 2008.

[12]  Brigitte Pientka A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions , 2008, POPL '08.

[13]  George C. Necula,et al.  Proof-carrying code , 1997, POPL '97.

[14]  Stephanie Weirich,et al.  Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism , 2003, ICFP '03.

[15]  Frank Pfenning,et al.  Higher-order abstract syntax , 1988, PLDI '88.

[16]  Fairouz Kamareddine,et al.  Reviewing the Classical and the de Bruijn Notation for [lambda]-calculus and Pure Type Systems , 2001, J. Log. Comput..

[17]  Xavier Leroy,et al.  Formal Verification of a C Compiler Front-End , 2006, FM.

[18]  Tim Sheard,et al.  Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space) , 1996, POPL '96.

[19]  Andrew W. Appel,et al.  A type-based compiler for standard ML , 1995, PLDI '95.

[20]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[21]  Brigitte Pientka,et al.  Programming with proofs and explicit contexts , 2008, PPDP '08.

[22]  Andrew W. Appel,et al.  Space-efficient closure representations , 1994, LFP '94.

[23]  Zhong Shao,et al.  A type system for certi .ed binaries , 2002, Foundations of Intrusion Tolerant Systems, 2003 [Organically Assured and Survivable Information Systems].

[24]  James Cheney,et al.  First-Class Phantom Types , 2003 .

[25]  Zhong Shao Flexible representation analysis , 1997, ICFP '97.

[26]  Emir Pasalic,et al.  Meta-programming With Built-in Type Equality , 2008, Electron. Notes Theor. Comput. Sci..

[27]  Stefan Monnier,et al.  Type-Safe Code Transformations in Haskell , 2007, Electron. Notes Theor. Comput. Sci..

[28]  Chiyan Chen,et al.  Implementing typeful program transformations , 2003, PPoPP 2003.

[29]  Olivier Danvy,et al.  Representing Control: a Study of the CPS Transformation , 1992, Mathematical Structures in Computer Science.

[30]  Simon L. Peyton Jones,et al.  System F with type equality coercions , 2007, TLDI '07.

[31]  Nathan Mishra-Linger,et al.  Programming in Omega , 2008, CEFP.

[32]  Zhong Shao,et al.  Fully reflexive intensional type analysis , 2000, ICFP '00.

[33]  Xavier Leroy,et al.  Unboxed objects and polymorphic typing , 1992, POPL '92.

[34]  Gang Chen,et al.  Guarded recursive datatype constructors , 2003, POPL '03.

[35]  Simon Peyton Jones,et al.  Towards open type functions for Haskell , 2007 .

[36]  Stefan Monnier,et al.  A type-preserving closure conversion in haskell , 2007, Haskell '07.

[37]  Xavier Leroy,et al.  Formal certification of a compiler back-end or: programming a compiler with a proof assistant , 2006, POPL '06.