Skip to main content Accessibility help
×
Home

Correctness of compiling polymorphism to dynamic typing*

  • KUEN-BANG HOU (Favonia) (a1), NICK BENTON (a2) and ROBERT HARPER (a3)

Abstract

The connection between polymorphic and dynamic typing was originally considered by Curry et al. (1972, Combinatory Logic, vol. ii) in the form of “polymorphic type assignment” for untyped λ-terms. Types are assigned after the fact to what is, in modern terminology, a dynamic language. Interest in type assignment was revitalized by the proposals of Bracha et al. (1998, OOPSLA) and Bank et al. (1997, POPL) to enrich Java with polymorphism (generics), which in turn sparked the development of other languages, such as Scala, with similar combinations of features. In such a setting, where the target language already has a monomorphic type system, it is desirable to compile polymorphism to dynamic typing in such a way that as much static typing as possible is preserved, relying on dynamics only insofar as genericity is actually required. The basic approach is to compile polymorphism using embeddings from each type into a universal “top” type, ${\mathbb{D}}$ , and partial projections that go in the other direction. This scheme is intuitively reasonable, and, indeed, has been used in practice many times. Proving its correctness, however, is non-trivial. This paper studies the compilation of System F to an extension of Moggi's computational meta-language with a dynamic type and shows how the compilation may be proved correct using a logical relation.

Copyright

Footnotes

Hide All
*

This research is sponsored in part by the National Science Foundation under Grant Number 1116703. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

Footnotes

References

Hide All
Ahmed, A. (2006) Step-indexed syntactic logical relations for recursive and quantified types. In Programming Languages and Systems, Sestoft, Peter (ed), Lecture Notes in Computer Science, vol. 3924. Berlin, Heidelberg: Springer, pp. 6983.
Ahmed, A., Findler, R. B., Siek, J. G. & Wadler, P. (2011) Blame for all. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 201–214.
Amadio, R. (1993) On the adequacy of PER models. In Proceedings of the 18th International Symposium on Mathematical Foundations of Computer Science (MFCS). LNCS, vol. 711. Berlin, Heidelberg: Springer, pp. 222–231.
Appel, A. W. & McAllester, D. (2001) An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst. 23 (5), 657683.
Bank, J. A., Myers, A. C. & Liskov, B. (1997) Parameterized types for Java. In Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 132–145.
Benton, N. (2005) Embedded interpreters. J. Funct. Program. 15 (4), 503542.
Benton, N. & Hur, C.-K. (2010) Realizability and Compositional Compiler Correctness for a Polymorphic Language. Technical Report, MSR-TR-2010-62. Microsoft Research.
Bracha, G., Odersky, M., Stoutamire, D. & Wadler, P. (1998) Making the future safe for the past: adding genericity to the Java programming language. In Proceedings of the 1998 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages & Applications (OOPSLA '98), vol. 33. New York, NY, USA: ACM, pp. 183–200.
Crary, K. & Harper, R. (2007) Syntactic logical relations for polymorphic and recursive types. Electron. Notes Theor. Comput. Sci. 172, 259299.
Curry, H. B., Hindley, J. R. & Seldin, J. P. (1972) Combinatory Logic, Volume ii. Studies in logic and the foundations of mathematics, vol. 65. North-Holland Publishing Company.
Findler, R. B. & Felleisen, M. (2002) Contracts for higher-order functions. In Proceedings of the International Conference on Functional Programming (ICFP). New York, NY, USA: ACM, pp. 48–59. doi = 10.1145/581478.581484.
Girard, J.-Y. (1972) Interprétation fonctionnelle et élimination des coupures de l'arithmétique d'ordre supérieur. Ph.D. thesis, Université Paris 7.
Harper, R. (2012) Practical Foundations for Programming Languages. Cambridge University Press.
Hur, C.-K., & Dreyer, D. (2011) A Kripke logical relation between ML and assembly. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 133–146.
Igarashi, A., Pierce, B. C. & Wadler, P. (2001) Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst. 23 (3), 396450.
McCracken, N. 1979 (June) An Investigation of a Programming Language with a Polymorphic Type Structure. Ph.D. thesis, Syracuse University.
Meyer, A. R., & Wand, M. (1985) Continuation semantics in typed lambda-calculi. In Logics of Programs, Rohit Parikh (ed), Lecture Notes in Computer Science, vol. 193. Berlin, Heidelberg: Springer, pp. 219224.
Milner, R. (1978) A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17 (3), 348374.
Minamide, Y., Morrisett, G. & Harper, Rt. (1996) Typed closure conversion. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 271–283.
Moggi, E. (1991) Notions of computation and monads. Inform. Comput. 93 (1), 5592.
Moors, A., Piessens, F. & Odersky, M. (2008) Generics of a higher kind. In Proceedings of the 23rd ACM SIGPLAN Conference on Object-Oriented Programming Systems Languages and Applications (OOPSLA). New York, NY, USA: ACM, pp. 423–438.
Pitts, A. M. (1996) Relational properties of domains. Inform. Comput. 127 (2), 6690.
Plotkin, G. D. (1977) LCF considered as a programming language. Theor. Comput. Sci. 5 (3), 223255.
Ramsey, N. (2011) Embedding an interpreted language using higher-order functions and types. J. Funct. Program. 21 (6), 585615.
Reynolds, J. (1983) Types, abstraction and parametric polymorphism. InInformation Processing 83. IFIP Congress Series, vol. 9. North-Holland, pp. 513523.
Reynolds, J. C. (1974) Towards a theory of type structure. In Programming Symposium, Proceedings Colloque sur la Programmation. Berlin, Heidelberg: Springer-Verlag, pp. 408–423.
Rossberg, A., Russo, C. V., & Dreyer, D. (2010) F-ing modules. In Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI). New York, NY, USA: ACM, pp. 89–102.
Scott, D. (1976) Data types as lattices. SIAM J. Comput. 5 (3), 522587.

Related content

Powered by UNSILO

Correctness of compiling polymorphism to dynamic typing*

  • KUEN-BANG HOU (Favonia) (a1), NICK BENTON (a2) and ROBERT HARPER (a3)

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed.

Correctness of compiling polymorphism to dynamic typing*

  • KUEN-BANG HOU (Favonia) (a1), NICK BENTON (a2) and ROBERT HARPER (a3)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *