Hostname: page-component-7c8c6479df-24hb2 Total loading time: 0 Render date: 2024-03-19T10:36:26.231Z Has data issue: false hasContentIssue false

Type inference with simple subtypes

Published online by Cambridge University Press:  07 November 2008

John C. Mitchell
Affiliation:
Department of Computer Science, Margaret Jacks Hall, Stanford University, Stanford, CA 94305-2140USA
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Subtyping appears in a variety of programming languages, in the form of the ‘automatic coercion’ of integers to reals, Pascal subranges, and subtypes arising from class hierarchies in languages with inheritance. A general framework based on untyped lambda calculus provides a simple semantic model of subtyping and is used to demonstrate that an extension of Curry's type inference rules are semantically complete. An algorithm G for computing the most general typing associated with any given expression, and a restricted, optimized algorithm GA using only atomic subtyping hypotheses are developed. Both algorithms may be extended to insert type conversion functions at compile time or allow polymorphic function declarations as in ML.

Type
Articles
Copyright
Copyright © Cambridge University Press 1991

References

Aho, A. V., Hopcroft, J. E. and Ullman, J. D. 1983. Data Structures and Algorithms. Addison-Wesley.Google Scholar
Aho, A. V., Sethi, R. and Ullman, J. D. 1986. Compilers: principles, techniques, tools. Addison-Wesley.Google Scholar
Barendregt, H. P. 1984. The Lambda Calculus: Its Syntax and Semantics. North-Holland.Google Scholar
Barendregt, H., Coppo, M. and Dezani-Ciancaglini, M. 1983. A Filter Lambda Model and the Completeness of Type Assignment. J. Symbolic Logic, 48 (4): 931940.CrossRefGoogle Scholar
Cardelli, L. 1988. A Semantics of Multiple Inheritance. Information and Computation, 76: 138164.CrossRefGoogle Scholar
Cardelli, L. and Mitchell, J. C. Operations on records. To appear in Math. Foundations of Prog. Lang. Semantics.Google Scholar
Coppo, M., Dezani-Ciancaglini, M. and Venneri, B. 1980. Principal type schemes and lambda calculus semantics. In Seldin, J. P. and Hindley, J. (editors), To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pp. 535560. Academic Press.Google Scholar
Coppo, M. 1983. On the semantics of polymorphism. Acta Informatica 20: 159170.CrossRefGoogle Scholar
Curry, H. B. and Feys, R. 1958. Combinatory Logic I. North-Holland.Google Scholar
Damas, L. and Milner, R. 1982. Principal Type Schemes for Functional Programs. In 9th ACM Symposium on Principles of Programming Languages, pp. 207212.Google Scholar
Dwork, C., Kanellakis, P. and Mitchell, J. C. 1984. On the Sequential Nature of Unification. J. of Logic Programming, 1: 3550.CrossRefGoogle Scholar
Fuh, Y.-C. and Mishra, P. 1988. Type Inference with Subtypes. In ESOP-88, (Mar).CrossRefGoogle Scholar
Gordon, M. J., Milner, R. and Wadsworth, C. P. 1979. Edinburgh LCF. Volume 78 of Lecture Notes in Computer Science, Springer-Verlag.Google Scholar
Hindley, R. 1969. The Principal Type-Scheme of an Object in Combinatory Logic. Trans. AMS, 146: 2960.Google Scholar
Hindley, R. 1983 a. The Completeness Theorem for Typing Lambda Terms. Theor. Comp. Sci., 22: 117.CrossRefGoogle Scholar
Hindley, R. 1983 b. Curry's Type Rules Are Complete with Respect to the F-semantics Too. Theor. Comp. Sci., 22: 127133.CrossRefGoogle Scholar
Jategaonkar, L. and Mitchell, J. C. 1988. ML with extended pattern matching and subtypes. In Proc. ACM Symp. Lisp and Functional Programming Languages, pp. 198212 (Jul).CrossRefGoogle Scholar
Kanellakis, P. C. and Mitchell, J. C. 1989. Polymorphic unification and ML typing. In 16th ACM Symposium on Principles of Programming Languages, pp. 105115.Google Scholar
Kanellakis, P. C., Mairson, H. G. and Mitchell, J. C. Unification and ML type reconstruction. To appear in Computational Logic, essays in honor of Alan Robinson. MIT Press.Google Scholar
Lambek, J. and Scott, P. J. 1986. Introduction to Higher-Order Categorical Logic. Cambridge University Press.Google Scholar
Leivant, D. 1983. Polymorphic Type Inference. In Proc. 10th ACM Symp. on Principles of Programming Languages, pp. 8898.Google Scholar
Mac Lane, S. 1971. Categories for the Working Mathematician. Volume 5 of Graduate Texts in Mathematics, Springer-Verlag.Google Scholar
MacQueen, D. and Sethi, R. 1982. A Semantic Model of Types for Applicative Languages. In ACM Symp. on Lisp and Functional Programming, pp. 243252.Google Scholar
MacQueen, D., Plotkin, G. and Sethi, R. 1986. An ideal model for recursive polymorphic types. Information and Control, 71 (1/2): 95130.CrossRefGoogle Scholar
Meyer, A. R. 1982. What Is A Model of the Lambda Calculus? Information and Control, 52 (1): 87122.CrossRefGoogle Scholar
Milner, R. 1978. A Theory of Type Polymorphism in Programming. JCSS, 17: 348375.Google Scholar
Mitchell, J. C. 1984. Coercion and Type Inference (Summary). In Proc. 11th ACM Symp. on Principles of Programming Languages, pp. 175185 (Jan).CrossRefGoogle Scholar
Mitchell, J. C. 1988. Polymorphic type inference and containment. Information and Computation, 76 (2/3).CrossRefGoogle Scholar
Mitchell, J. C. 1990. Type systems for programming languages. In van Leeuwen, J. (editor), Handbook of Theoretical Computer Science, Volume B, pp. 365458. North-Holland.Google Scholar
Paterson, M. S. and Wegman, M. N. 1978. Linear Unification. JCSS 16: 158167.Google Scholar
Remy, D. 1989. Typechecking records and variants in a natural extension of ML. In 16th ACM Symposium on Principles of Programming Languages, pp. 6076.Google Scholar
Reynolds, J. C. 1980. Using Category Theory to Design Implicit Conversions and Generic Operators. Volume 94 of Lecture Notes in Computer Science, Springer-Verlag, pp. 2112580.Google Scholar
Robinson, J. A. 1965. A Machine Oriented Logic Based on the Resolution Principle. J. ACM 12 (1): 2341.CrossRefGoogle Scholar
Scott, D. 1976. Data Types as Lattices. Siam J. Computing, 5 (3): 522587.CrossRefGoogle Scholar
Scott, D. S. 1980. Relating theories of the lambda calculus. In Seldin, J. P. and Hindley, J. (editors), To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pp. 403450. Academic Press.Google Scholar
Smyth, M. and Plotkin, G. D. 1982. The category-theoretic solution of recursive domain equations. SIAM J. Computing, 11: 761783.CrossRefGoogle Scholar
Stroustrop, B. 1986. The $Cˇ{+ +}$ Programming Language. Addison-Wesley.Google Scholar
Wand, M. 1987. Complete Type Inference for Simple Objects. In Proc. 2nd IEEE Symp. on Logic in Computer Science, pp. 3744. (Corrigendum in Proc. 3rd IEEE Symp. on Logic in Computer Science, p. 132.)Google Scholar
Wand, M. and O'Keefe, P. 1989. On the complexity of type inference with coercion. In Proc. ACM Conf. Functional Programming and Computer Architecture, pp. 293298.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.