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
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- chakGoogle Scholar
- :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 Scholar
Digital Library
- James Cheney and Ralf Hinze. First-class phantom types. CUCIS TR2003--1901, Cornell University, 2003.Google Scholar
- 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 Scholar
Digital Library
- Matthew Gertz. Scaling up: The very busy background compiler. phMSDN Magazine, 6 2005. URL http://msdn.microsoft.com/en-us/magazine/cc163781.aspx.Google Scholar
- 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 Scholar
Digital Library
- Fritz Henglein. Dynamic typing: syntax and proof theory. phScience of Computer Programming, 22: 197--230, June 1994. ISSN 0167--6423. Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- nd Launchbury(1991)}peyton-jonesGoogle Scholar
- :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 Scholar
Digital Library
- Simon Peyton Jones and André Santos. A transformation-based optimiser for Haskell. phScience of Computer Programming, 32 (1--3): 3--47, September 1998. Google Scholar
Digital Library
- t al.(2006)Peyton Jones, Vytiniotis, Weirich, and Washburn}spjGoogle Scholar
- :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 Scholar
Digital Library
- t al.(2007)Peyton Jones, Vytiniotis, Weirich, and Shields}peyton-jonesGoogle Scholar
- :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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In phScheme and Functional Programming Workshop, pages 81--92, September 2006.Google Scholar
- 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 Scholar
Digital Library
- and Donnelly}sulzmannGoogle Scholar
- :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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- }coqThe Coq Team. phCoq. URL http://coq.inria.fr.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Equality proofs and deferred type errors: a compiler pearl






Comments