research-article

Equality proofs and deferred type errors: a compiler pearl

Published:09 September 2012Publication History

Abstract

The Glasgow Haskell Compiler is an optimizing compiler that expresses and manipulates first-class equality proofs in its intermediate language. We describe a simple, elegant technique that exploits these equality proofs to support deferred type errors. The technique requires us to treat equality proofs as possibly-divergent terms; we show how to do so without losing either soundness or the zero-overhead cost model that the programmer expects.

References

  1. Andreas Abel. Irrelevance in type theory with a heterogeneous equality judgement. In phFoundations of Software Science and Computational Structures, 14th International Conference, FOSSACS 2011, pages 57--71. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. Blame for all. In phProceedings of the 38th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '11, pages 201--214, New York, NY, USA, 2011. ACM. ISBN 978--1--4503-0490-0. 10.1145/1926385.1926409.Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Bruno Barras and Bruno Bernardo. The implicit calculus of constructions as a programming language with dependent types. In phFoundations of Software Science and Computation Structure, pages 365--379, 2008. 10.1007/978--3--540--78499--9_26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Michael Bayne, Richard Cook, and Michael Ernst. Always-available static and dynamic feedback. In phProceedings of 33rd International Conference on Software Engineering (ICSE'11), pages 521--530, Hawaii, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Jesper Bengtson, Karthikeyan Bhargavan, Cédric Fournet, Andrew D. Gordon, and Sergio Maffeis. Refinement types for secure implementations. In phProceedings of the 2008 21st IEEE Computer Security Foundations Symposium, pages 17--32, Washington, DC, USA, 2008. IEEE Computer Society. ISBN 978-0--7695--3182--3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Johannes Borgstrom, Juan Chen, and Nikhil Swamy. Verifying stateful programs with substructural state and Hoare types. In phProceedings of the 5th ACM Workshop on Programming Languages meets Program Verification, PLPV '11, pages 15--26, New York, NY, USA, 2011. ACM. ISBN 978--1--4503-0487-0. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Ana Bove, Peter Dybjer, and Ulf Norell. A brief overview of Agda -- a functional language with dependent types. In phTPHOLs '09: Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics, pages 73--78, Berlin, Heidelberg, 2009. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Edwin Brady, Conor McBride, and James McKinna. Inductive families need not store their indices. In Stefano Berardi, Mario Coppo, and Ferruccio Damiani, editors, phTYPES, volume 3085 of phLecture Notes in Computer Science, pages 115--129. Springer, 2003.Google ScholarGoogle Scholar
  9. chakGoogle ScholarGoogle Scholar
  10. :synonymsManuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms. In phICFP '05: Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming, pages 241--253, New York, NY, USA, 2005. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. James Cheney and Ralf Hinze. First-class phantom types. CUCIS TR2003--1901, Cornell University, 2003.Google ScholarGoogle Scholar
  12. Cormac Flanagan. Hybrid type checking. In phProceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '06, pages 245--256, New York, NY, USA, 2006. ACM. 10.1145/1111037.1111059. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Matthew Gertz. Scaling up: The very busy background compiler. phMSDN Magazine, 6 2005. URL http://msdn.microsoft.com/en-us/magazine/cc163781.aspx.Google ScholarGoogle Scholar
  14. Christian Haack and J. B. Wells. Type error slicing in implicitly typed higher-order languages. phScience of Computer Programming, 50: 189--224, March 2004. ISSN 0167--6423. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Fritz Henglein. Dynamic typing: syntax and proof theory. phScience of Computer Programming, 22: 197--230, June 1994. ISSN 0167--6423. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. and Shan}Kiselyov09funwithOleg Kiselyov, Simon Peyton Jones, and Chung-chieh Shan. Fun with type functions. In A.W. Roscoe, Cliff B. Jones, and Kenneth R. Wood, editors, phReflections on the Work of C.A.R. Hoare, History of Computing, pages 301--331. Springer London, 2010. 10.1007/978--1--84882--912--1_14.Google ScholarGoogle Scholar
  17. el and Peyton Jones(2005)}laemmel-pj:syb-with-classRalf L\"ammel and Simon Peyton Jones. Scrap your boilerplate with class: extensible generic functions. In phProceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, ICFP '05, pages 204--215, New York, NY, USA, 2005. ACM. 10.1145/1086365.1086391. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Daniel R. Licata and Robert Harper. A formulation of dependent ML with explicit equality proofs. Technical Report Carnegie Mellon University-CS-05--178, Carnegie Mellon University Department of Computer Science, 2005.Google ScholarGoogle Scholar
  19. Daniel R. Licata and Robert Harper. Canonicity for 2-dimensional type theory. In phProceedings of the 39th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '12, pages 337--348, New York, NY, USA, 2012. ACM. 10.1145/2103656.2103697. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Zhaohui Luo. Coercions in a polymorphic type system. phMathematical Structures in Computer Science, 18 (4): 729--751, August 2008. ISSN 0960--1295. 10.1017/S0960129508006804. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Alexandre Miquel. The implicit calculus of constructions: extending pure type systems with an intersection type binder and subtyping. In phProceedings of the 5th International Conference on Typed Lambda Calculi and Applications, TLCA'01, pages 344--359, Berlin, Heidelberg, 2001. Springer-Verlag. ISBN 3--540--41960--8. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Nathan Mishra-Linger and Tim Sheard. Erasure and polymorphism in pure type systems. In Roberto Amadio, editor, phFoundations of Software Science and Computational Structures, volume 4962 of phLecture Notes in Computer Science, pages 350--364. Springer Berlin / Heidelberg, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Ulf Norell. phTowards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, September 2007.Google ScholarGoogle Scholar
  24. nd Launchbury(1991)}peyton-jonesGoogle ScholarGoogle Scholar
  25. :unboxedSimon Peyton Jones and John Launchbury. Unboxed values as first class citizens in a non-strict functional programming language. In phFPCA91: Conference on Functional Programming Languages and Computer Architecture, pages 636--666, New York, NY, August 1991. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Simon Peyton Jones and André Santos. A transformation-based optimiser for Haskell. phScience of Computer Programming, 32 (1--3): 3--47, September 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. t al.(2006)Peyton Jones, Vytiniotis, Weirich, and Washburn}spjGoogle ScholarGoogle Scholar
  28. :gadtSimon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. Simple unification-based type inference for GADTs. In phProceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, pages 50--61, New York, NY, USA, 2006. ACM Press. ISBN 1--59593--309--3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. t al.(2007)Peyton Jones, Vytiniotis, Weirich, and Shields}peyton-jonesGoogle ScholarGoogle Scholar
  30. :practicalSimon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. Practical type inference for arbitrary-rank types. phJournal of Functional Programming, 17 (01): 1--82, 2007. 10.1017/S0956796806006034. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Benjamin C. Pierce and David N. Turner. Local type inference. phACM Transactions on Programming Languages and Systems, 22 (1): 1--44, January 2000. ISSN 0164-0925. 10.1145/345099.345100. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. y(2005)}pottier:pierce-chapterFrançois Pottier and Didier Rémy. The essence of ML type inference. In Benjamin C. Pierce, editor, phAdvanced Topics in Types and Programming Languages, chapter 10, pages 389--489. MIT Press, 2005.Google ScholarGoogle Scholar
  33. Tim Sheard and Emir Pasalic. Meta-programming with built-in type equality. In phProc 4th International Workshop on Logical Frameworks and Meta-languages (LFM'04), pages 106--124, July 2004.Google ScholarGoogle Scholar
  34. Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In phScheme and Functional Programming Workshop, pages 81--92, September 2006.Google ScholarGoogle Scholar
  35. Jeremy G. Siek and Manish Vachharajani. Gradual typing with unification-based inference. In phProceedings of the 2008 symposium on Dynamic languages, DLS '08, pages 7:1--7:12, New York, NY, USA, 2008. ACM. 10.1145/1408681.1408688. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. and Donnelly}sulzmannGoogle ScholarGoogle Scholar
  37. :fc-paperMartin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In phProceedings of the 2007 ACM SIGPLAN Workshop on Types in Language Design and Implementation, pages 53--66, New York, NY, USA, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Nikhil Swamy, Michael Hicks, and Gavin M. Bierman. A theory of typed coercions and its applications. In phProceedings of the 14th ACM SIGPLAN International Conference on Functional Programming, ICFP '09, pages 329--340, New York, NY, USA, 2009. ACM. ISBN 978--1--60558--332--7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Nikhil Swamy, Juan Chen, Cedric Fournet, Pierre-Yves Strub, Karthikeyan Bharagavan, and Jean Yang. Secure distributed programming with value-dependent types. In phProceedings of the 16th ACM SIGPLAN International Conference on Functional Programming, ICFP'11, pages 266--278. ACM, September 2011. 10.1145/2034773.2034811. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. }coqThe Coq Team. phCoq. URL http://coq.inria.fr.Google ScholarGoogle Scholar
  41. Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage migration: from scripts to programs. In phCompanion to the 21st ACM SIGPLAN Symposium on Object-Oriented Programming Systems, Languages, and Applications, OOPSLA '06, pages 964--974, New York, NY, USA, 2006. ACM. 10.1145/1176617.1176755. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Schrijvers, and Sulzmann}pjv:modularDimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. OutsideIn(X): Modular Type inference with local assumptions. phJournal of Functional Programming, 21, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Stephanie Weirich, Dimitrios Vytiniotis, Simon Peyton Jones, and Steve Zdancewic. Generative type abstraction and type-level computation. In phProceedings of the 38th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '11, pages 227--240, New York, NY, USA, 2011. ACM. ISBN 978--1--4503-0490-0. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Andrew K. Wright and Robert Cartwright. A practical soft type system for scheme. phACM Transactions on Programming Languages and Systems, 19 (1): 87--152, January 1997. ISSN 0164-0925. 10.1145/239912.239917. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalh\ aes. Giving Haskell a promotion. In phProceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation, TLDI '12, pages 53--66, New York, NY, USA, 2012. ACM. 10.1145/2103786.2103795. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Equality proofs and deferred type errors: a compiler pearl

      Comments

      Login options

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

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 47, Issue 9
        ICFP '12
        September 2012
        368 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2398856
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programming
          September 2012
          392 pages
          ISBN:9781450310543
          DOI:10.1145/2364527

        Copyright © 2012 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 9 September 2012

        Check for updates

        Qualifiers

        • research-article

      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!