skip to main content
10.1145/1411204.1411218acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

A type-preserving compiler in Haskell

Published:20 September 2008Publication History

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.

Skip Supplemental Material Section

Supplemental Material

Video

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. James Cheney and Ralf Hinze. First-class phantom types. Technical Report CUCIS TR2003-1901, Cornell University, 2003.Google ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In International Conference on Functional Programming. ACM Press, September 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science, 2 (4):361--391, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Louis-Julien Guillemette and Stefan Monnier. A type-preserving closure conversion in Haskell. In Haskell Workshop. ACM Press, September 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Louis-Julien Guillemette and Stefan Monnier. One vote for type families in Haskell! In The 9th symposium on Trends in Functional Programming, 2008.Google ScholarGoogle Scholar
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. Fairouz Kamareddine. Reviewing the classical and the de bruijn notation for λ-calculus and pure type systems. Journal of Logic and Computation, 11, 2001.Google ScholarGoogle Scholar
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. Nathan Linger and Tim Sheard. Programming with static invariants in Omega. Unpublished, 2004.Google ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. Simon Peyton-Jones et al. The Haskell Prime Report. Working Draft, 2007.Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. Brigitte Pientka and Joshua Dunfield. Programming with proofs and explicit contexts. In Symposium on Principles and Practice of Declarative Programming, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. François Pottier and Nadji Gauthier. Polymorphic typed defunctionalization. SIGPLAN Not., 39(1):89--98, 2004. ISSN 0362-1340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Tom Schrijvers, Martin Sulzmann, Simon Peyton Jones, and Manuel M. T. Chakravarty. Towards open type functions for Haskell. Presented at IFL 2007, 2007.Google ScholarGoogle Scholar
  24. Zhong Shao. An overview of the FLINT/ML compiler. In International Workshop on Types in Compilation, June 1997.Google ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A type-preserving compiler in Haskell

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!