Correctness of compiling polymorphism to dynamic typing

نویسندگان

  • Kuen-Bang Hou
  • Nick Benton
  • Robert Harper
چکیده

The connection between polymorphic and dynamic typing was originally considered by Curry et al. (1972) 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) and Bank et al. (1997) 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, D, and partial projections that go in the other direction. This scheme is intuitively reasonable, and, indeed, has been used in practice many times (Igarashi et al., 2001). Proving its correctness, however, is non-trivial. This paper studies the compilation of System F to an extension of Moggi’s computational metalanguage with a dynamic type and shows how the compilation may be proved correct using a logical relation. ∗ 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. ZU064-05-FPR poly2dyn 12 December 2016 22:1 2 K. Hou (Favonia), N. Benton, and R. Harper

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Type Refinements for Compiler Correctness

Type refinements, introduced by Freeman and Pfenning and explored by Davies and Dunfield, unify the ontological and epistemic views of typing. Types tell us what programming language constructs exist, whereas refinements express properties of the values of a type. Here we show that refinements are very useful in compiler correctness proofs, wherein it often arises that two expressions that are ...

متن کامل

Implicit Typing à la ML for the Join-Calculus

We adapt the Damas-Milner typing discipline to the join-calculus. The main result is a new generalization criterion that extends the polymorphism of ML to join-de nitions. We prove the correctness of our typing rules with regard to a chemical semantics. We also relate typed extensions of the core join-calculus to functional languages.

متن کامل

Kinded Parameteric Overloading

The combination of overloading and parametric polymorphism has received some attention in the functional programming community. The main approach has been that of Haskell type classes. An approach to the type-checking and semantics of parametric overloading is presented, based on using structured kinds to constrain type variables. Open kinds constrain type variables by sets of operations and ar...

متن کامل

Trust, but Verify: Two-Phase Typing for Dynamic Languages

A key challenge when statically typing so-called dynamic languages is the ubiquity of value-based overloading, where a given function can dynamically reflect upon and behave according to the types of its arguments. Thus, to establish basic types, the analysis must reason precisely about values, but in the presence of higher-order functions and polymorphism, this reasoning itself can require bas...

متن کامل

A First-Order Theory of Types and Polymorphism in Logic Programming

We describe a new logic called typed predicate calculus (T PC) that gives declarative meaning to logic programs with type declarations and type inference. T PC supports all popular types of polymorphism, such as parametric, inclusion, and ad hoc polymorphism. The proper interaction between parametric and inclusion varieties of polymorphism is achieved through a new construct, called type depend...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • J. Funct. Program.

دوره 27  شماره 

صفحات  -

تاریخ انتشار 2017