An Unboxed Operational Semantics for ML Polymorphism

We present an unboxed operational semantics for an ML-style polymorphic language. Different from the conventional formalisms, the proposed semantics accounts for actual representations of run-time objects of various types, and supports a refined notion of polymorphism that allows polymorphic functions to be applied directly to values of various different representations. In particular, polymorphic functions can receive multi-word constants such as floating-point numbers without requiring them to be “boxed” (i.e., heap allocated.) This semantics will serve as an alternative basis for implementing polymorphic languages. The development of the semantics is based on the technique of the type-inference-based compilation for polymorphic record operations [20]. We first develop a lower-level calculus, called a polymorphic unboxed calculus, that accounts for direct manipulation of unboxed values in a polymorphic language. This unboxed calculus supports efficient value binding through integer representation of variables. Different from de Bruijn indexes, our integer representation of a variable corresponds to the actual offset to the value in a run-time environment consisting of objects of various sizes. Polymorphism is supported through an abstraction mechanism over argument sizes. We then develop an algorithm that translates ML into the polymorphic unboxed calculus by using type information obtained through type inference. At the time of polymorphic let binding, the necessary size abstractions are inserted so that a polymorphic function is translated into a function that is polymorphic not only in the type of the argument but also in its size. The ML type system is shown to be sound with respect to the operational semantics realized by the translation.

[1]  Pierre-Louis Curien,et al.  The Categorical Abstract Machine , 1987, Sci. Comput. Program..

[2]  Xavier Leroy,et al.  Unboxed objects and polymorphic typing , 1992, POPL '92.

[3]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[4]  Atsushi Ohori,et al.  A simple semantics for ML polymorphism , 1989, FPCA.

[5]  Richard C. H. Connor,et al.  An ad hoc approach to the implementation of polymorphism , 1991, TOPL.

[6]  Fritz Henglein,et al.  Formally optimal boxing , 1994, POPL '94.

[7]  Robert Harper,et al.  Compiling with Non-Parametric Polymorphism (Preliminary Report) , 1994 .

[8]  John Peterson,et al.  Implementing type classes , 1993, PLDI '93.

[9]  Philip Wadler,et al.  The Glasgow Haskell Compiler: a technical overview , 1993 .

[10]  Andrew W. Appel,et al.  Standard ML of New Jersey , 1991, PLILP.

[11]  de Ng Dick Bruijn,et al.  Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem , 1972 .

[12]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[13]  Atsushi Ohori,et al.  A polymorphic record calculus and its compilation , 1995, TOPL.

[14]  Simon L. Peyton Jones,et al.  Unboxed Values as First Class Citizens in a Non-Strict Functional Language , 1991, FPCA.

[15]  Xavier Leroy,et al.  Polymorphic typing of an algorithmic language , 1992 .

[16]  Xavier Leroy,et al.  The ZINC experiment : an economical implementation of the ML language , 1990 .

[17]  Robin Milner,et al.  Definition of standard ML , 1990 .

[18]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[19]  Robert Harper,et al.  Compiling with Non-Parametric Polymorphism. , 1994 .

[20]  Miles H. Krumbine Hell , 1930, The Journal of Religion.

[21]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[22]  John C. Mitchell,et al.  On the type structure of standard ML , 1993, TOPL.

[23]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[24]  M. Tofte Operational Semantics and Polymorphic Type Inference , 1988 .

[25]  Atsushi Ohori,et al.  A compilation method for ML-style polymorphic record calculi , 1992, POPL '92.

[26]  Andrew W. Appel,et al.  Unrolling lists , 1994, LFP '94.

[27]  Peter Thiemann,et al.  Unboxed values and polymorphic typing revisited , 1995, FPCA '95.

[28]  Cordelia V. Hall Using Hindley-Milner type inference to optimise list representation , 1994, LFP '94.

[29]  Andrew P. Tolmach Tag-free garbage collection using explicit type parameters , 1994, LFP '94.