Abstract
Polymorphic equality is a controversial language construct. While being convenient for the programmer, it has been argued that polymorphic equality (1) invites to violation of software engineering principles, (2) lays a serious burden on the language implementor, and (3) enforces a runtime overhead due to the necessity of tagging values at runtime. We show that neither (2) nor (3) are inherent to polymorphic equality by showing that one can compile programs with polymorphic equality into programs without polymorphic equality in such a way that there is no need for tagging or for runtime type analysis. Also, the translation is the identity on programs that do not use polymorphic equality. Experimental results indicate that even for programs that use polymorphic equality, the translation gives good results.
Preview
Unable to display preview. Download preview PDF.
References
Andrew Appel. Compiling With Continuations. Cambridge University Press, 1992.
Andrew Appel. A critique of Standard ML. In Journal of Functional Programming, pages 3(4): 391–429, October 1993.
Lars Birkedal, Mads Tofte, and Magnus Vejlstrup. From region inference to von Neumann machines via region representation inference. In 23st ACM Symposium on Principles of Programming Languages, January 1996.
Nikolaj Bjørner. Minimal typing derivations. In ACM Workshop on Standard ML and its Applications, June 1994.
Martin Elsman and Niels Hallenberg. An optimizing backend for the ML Kit using a stack of regions. Student Project, July 1995.
Robert Harper and Chris Stone. An interpretation of Standard ML in type theory. Technical report, Carnegie Mellon University, June 1997. CMU-CS-97-147.
Fritz Henglein and Jesper Jørgensen. Formally optimal boxing. In 21st ACM Symposium on Principles of Programming Languages, pages 213–226, January 1994.
Mark Jones. Dictionary-free overloading by partial evaluation. In ACM Workshop on Partial Evaluation and Semantics-Based Program Manipulation, Orlando, Florida, June 1994.
Xavier Leroy. Unboxed objects and polymorphic typing. In 19th ACM Symposium on Principles of Programming Languages, pages 177–188, 1992.
Xavier Leroy. The Objective Caml system. Software and documentation available on the Web, 1996.
Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997.
Greg Morrisett. Compiling with Types. PhD thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA 15213, December 1995.
Martin Odersky, Philip Wadler, and Martin Wehr. A second look at overloading. In 7’th International Conference on Functional Programming and Computer Architecture, June 1995.
Atsushi Ohori. A Polymorphic Record Calculus and its Compilation. ACM Transactions on Programming Languages and Systems, 17(6), November 1995.
Chris Okasaki. Purely Functional Data Structures. PhD thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA 15213, September 1996.
John Peterson and Mark Jones. Implementing type classes. In ACM Symposium on Programming Language Design and Implementation, June 1993.
Manuel Serrano and Pierre Weis. Bigloo: a portable and optimizing compiler for strict functional languages. In Second International Symposium on Static Analysis, pages 366–381, September 1995.
Zhong Shao. Typed common intermediate format. In 1997 USENIX Conference on Domain-Specific Languages, Santa Barbara, CA, Oct 1997.
Zhong Shao and Andrew Appel. A type-based compiler for Standard ML. Technical report, Yale University and Princeton University, November 1994.
David Tarditi, Greg Morrisett, Perry Cheng, Chris Stone, Robert Harper, and Peter Lee. TIL: A type-directed optimizing compiler for ML. In ACM Symposium on Programming Language Design and Implementation, 1996.
David Tarditi, Greg Morrisett, Perry Cheng, Chris Stone, Robert Harper, and Peter Lee. The TIL/ML compiler: Performance and safety through types. In Workshop on Compiler Support for Systems Software, 1996.
Mads Tofte. Type inference for polymorphic references. Information and Computation, 89(1), November 1990.
Mads Tofte, Lars Birkedal, Martin Elsman, Niels Hallenberg, Tommy Højfeld Olesen, Peter Sestoft, and Peter Bertelsen. Programming with regions in the ML Kit. Technical report, Department of Computer Science, University of Copenhagen, April 1997.
Mads Tofte and Jean-Pierre Talpin. Region-based memory management. Information and Computation, 132(2): 109–176, 1997.
Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In 16th ACM Symposium on Principles of Programming Languages, January 1989.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1998 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Elsman, M. (1998). Polymorphic equality — No tags required. In: Leroy, X., Ohori, A. (eds) Types in Compilation. TIC 1998. Lecture Notes in Computer Science, vol 1473. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0055516
Download citation
DOI: https://doi.org/10.1007/BFb0055516
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-64925-0
Online ISBN: 978-3-540-68308-7
eBook Packages: Springer Book Archive