ABSTRACT
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.
Supplemental Material
Available for Download
Supplemental material for: A type-preserving compiler in Haskell
- Sandrine Blazy, Zaynah Dargaye, and Xavier Leroy. Formal verification of a c compiler front-end. In International Symposium on Formal Methods, volume 4085 of Lecture Notes in Computer Science, pages 460--475, aug 2006. Google Scholar
Digital Library
- Chiyan Chen and Hongwei Xi. Implementing typeful program transformations. In PEPM '03: Proceedings of the 2003 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation, pages 20--28, New York, NY, USA, 2003. ACM Press. ISBN 1-58113-667-6. Google Scholar
Digital Library
- James Cheney and Ralf Hinze. First-class phantom types. Technical Report CUCIS TR2003-1901, Cornell University, 2003.Google Scholar
- Adam Chlipala. A certified type-preserving compiler from lambda calculus to assembly language. In Symposium on Programming Languages Design and Implementation, pages 54--65. ACM Press, June 2007. Google Scholar
Digital Library
- Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In International Conference on Functional Programming. ACM Press, September 2008. Google Scholar
Digital Library
- Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science, 2 (4):361--391, 1992.Google Scholar
Cross Ref
- Leonidas Fegaras and Tim Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In Conf. Record 23rd ACM SIGPLAN/SIGACT Symp. on Principles of Programming Languages, POPL'96, St. Petersburg Beach, FL, USA, 21-24 Jan. 1996, pages 284--294. ACM Press, New York, 1996. Google Scholar
Digital Library
- Louis-Julien Guillemette and Stefan Monnier. Type-safe code transformations in Haskell. In Programming Languages meets Program Verification, volume 174(7) of Electronic Notes in Theoretical Computer Science, pages 23--39, August 2006. Google Scholar
Digital Library
- Louis-Julien Guillemette and Stefan Monnier. A type-preserving closure conversion in Haskell. In Haskell Workshop. ACM Press, September 2007. Google Scholar
Digital Library
- Louis-Julien Guillemette and Stefan Monnier. One vote for type families in Haskell! In The 9th symposium on Trends in Functional Programming, 2008.Google Scholar
- Nadeem Abdul Hamid, Zhong Shao, Valery Trifonov, Stefan Monnier, and Zhaozhong Ni. A syntactic approach to foundational proof-carrying code. In Annual Symposium on Logic in Computer Science, pages 89--100, Copenhagen, Denmark, July 2002. Google Scholar
Digital Library
- Fairouz Kamareddine. Reviewing the classical and the de bruijn notation for λ-calculus and pure type systems. Journal of Logic and Computation, 11, 2001.Google Scholar
- Xavier Leroy. Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In Symposium on Principles of Programming Languages, pages 42--54, New York, NY, USA, January 2006. ACM Press. ISBN 1-59593-027-2. Google Scholar
Digital Library
- Nathan Linger and Tim Sheard. Programming with static invariants in Omega. Unpublished, 2004.Google Scholar
- Yasuhiko Minamide, Greg Morrisett, and Robert Harper. Typed closure conversion. In POPL '96: Proceedings of the 23rd ACM SIGPLANSIGACT symposium on Principles of programming languages, pages 271--283, New York, NY, USA, 1996. ACM. ISBN 0-89791-769-3. Google Scholar
Digital Library
- Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From system F to typed assembly language. ACM Transactions on Programming Languages and Systems, 21(3):527--568, 1999. Google Scholar
Digital Library
- George C. Necula. Proof-carrying code. In Conference Record of POPL '97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 106--119, Paris, France, jan 1997. Google Scholar
Digital Library
- Emir Pasalic. The Role of Type Equality in Meta-Programming. PhD thesis, Oregon Health and Sciences University, The OGI School of Science and Engineering, 2004. Google Scholar
Digital Library
- Simon Peyton-Jones et al. The Haskell Prime Report. Working Draft, 2007.Google Scholar
- Brigitte Pientka. A type-theoretic foundation for programming with higherorder abstract syntax and first-class substitutions. In Symposium on Principles of Programming Languages, pages 371--382, 2008. Google Scholar
Digital Library
- Brigitte Pientka and Joshua Dunfield. Programming with proofs and explicit contexts. In Symposium on Principles and Practice of Declarative Programming, 2008. Google Scholar
Digital Library
- François Pottier and Nadji Gauthier. Polymorphic typed defunctionalization. SIGPLAN Not., 39(1):89--98, 2004. ISSN 0362-1340. Google Scholar
Digital Library
- Tom Schrijvers, Martin Sulzmann, Simon Peyton Jones, and Manuel M. T. Chakravarty. Towards open type functions for Haskell. Presented at IFL 2007, 2007.Google Scholar
- Zhong Shao. An overview of the FLINT/ML compiler. In International Workshop on Types in Compilation, June 1997.Google Scholar
- Zhong Shao and Andrew W. Appel. A type-based compiler for Standard ML. In Symposium on Programming Languages Design and Implementation, pages 116--129, La Jolla, CA, June 1995. ACM Press. Google Scholar
Digital Library
- Zhong Shao, Bratin Saha, Valery Trifonov, and Nikolaos Papaspyrou. A type system for certified binaries. In Symposium on Principles of Programming Languages, pages 217--232, January 2002. Google Scholar
Digital Library
- Tim Sheard and Simon Peyton Jones. Template meta-programming for Haskell. In Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, pages 1--16, New York, NY, USA, 2002. ACM Press. ISBN 1-58113-605-6. Google Scholar
Digital Library
- Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In Types in Language Design and Implementation, January 2007. Google Scholar
Digital Library
- David Tarditi, Greg Morrisett, Perry Cheng, Christopher Stone, Robert Harper, and Peter Lee. TIL: A type-directed optimizing compiler for ML. In Symposium on Programming Languages Design and Implementation, pages 181--192, Philadelphia, PA, May 1996. ACM Press. Google Scholar
Digital Library
- Geoffrey Washburn and Stephanie Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, pages 249--262, Uppsala, Sweden, August 2003. ACM SIGPLAN. Google Scholar
Digital Library
- Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. In Symposium on Principles of Programming Languages, pages 224--235, New Orleans, LA, January 2003. Google Scholar
Digital Library
Index Terms
A type-preserving compiler in Haskell
Recommendations
A type-preserving compiler in Haskell
ICFP '08There 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 ...
A type-preserving closure conversion in haskell
Haskell '07: Proceedings of the ACM SIGPLAN workshop on Haskell workshopThe use of typed intermediate languages can significantly increase the reliability of a compiler. By type-checking the code produced at each transformation stage, one can identify bugs in the compiler that would otherwise be much harder to find. Also it ...
Type-Safe Code Transformations in Haskell
The use of typed intermediate languages can significantly increase the reliability of a compiler. By type-checking the code produced at each transformation stage, one can identify bugs in the compiler that would otherwise be much harder to find. We ...







Comments