Skip to main content
Log in

Proofs of a set of hybrid let-polymorphic type inference algorithms

  • Regular Papers
  • Published:
New Generation Computing Aims and scope Submit manuscript

Abstract

We present a generalized let-polymorphic type inference algorithm, prove that any of its instances is sound and complete with respect to the Hindley/Milner let-polymorphic type system, and find a condition on two instance algorithms so that one algorithm should find type errors earlier than the other.

By instantiating the generalized algorithm with different parameters, we can obtain not only the two opposite algorithms (the bottom-up standard algorithmW and the top-down algorithmM) but also other hybrid algorithms which are used in real compilers. Such instances’ soudness and completeness follow automatically, and their relative earliness in detecting type-errors is determined by checking a simple condition. The set of instances of the generalized algorithm is a superset of those used in the two most popular ML compilers: SML/NJ and OCaml.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Aiken, A. and Wimmers, E. L., “Type Inclusion Constraints and Type Inference,” inProc. of Functional Programming Languages and Computer Architecture, pp. 31–41, 1993.

  2. Beaven, M. and Stansifer, R., “Explaining Type Errors in Polymorphic Languages,”ACM Letters on Programming Languages and Systems, 2, pp. 17–30, Mar.–Dec. 1993.

    Article  Google Scholar 

  3. Bernstein, K. L. and Stark, E. W., “Debugging Type Errors (Full Version),”Technical Report, State University of New York at Stony Brook, 1995.

  4. Chitil, O., “Compositional Explanation of Types and Algorithmic Debugging of Type Errors,” inProc. of the 6th ACM SIGPLAN International Conference on Functional Programming, pp. 193–204, Sept. 2001.

  5. Cho, K. and Ueda, K., “Diagnosing Non-well-moded Concurrent Logic Programs,” inJoint International Conference on Logic Programming, pp. 215–229, MIT Press, 1996.

  6. Damas, L. and Milner, R., “Principal Type-scheme for Functional Programs,” inProc. of the 9th Annual ACM Symposium on Principles of Programming Languages, pp. 207–212, ACM Press, New York, 1982.

    Chapter  Google Scholar 

  7. Duggan, D., “Correct Type Explanation,” inProc. of Workshop on ML, pp. 49–58, 1998.

  8. Duggan, D. and Bent, F., “Explaining Type Inference,”Science of Computer Programming, 27, 1, pp. 37–83, July 1996.

    Article  MATH  Google Scholar 

  9. Henglein, F., “Type Inference with Polymorphic Recursion,”ACM Transactions on Programming Languages and Systems, 15, 2, pp. 253–289, April 1993.

    Article  Google Scholar 

  10. Lee, O. and Yi, K., “Proofs about a Folklore Let-polymorphic Type Inference Algorithm,”ACM Transactions on Programming Languages and Systems, 20, 4, pp. 707–723, July 1998.

    Article  Google Scholar 

  11. Leroy, X., Doligez, D., Garrigue, J., Rémy, D. and Vouillon, J., “The Objective Caml System Release 3.06,” Institut National de Recherche en Informatique et en Automatique, August 2002. http://caml.inria.fr.

  12. McAdam, B. J., “On the Unification of Substitutions in Type Inference,” inProc. of The International Workshop on Implementation of Functional Languages (Hammond, K., Davie, A. J. T. and Clack, C. eds.),vol. 1595 of Lecture Notes in Computer Science, pp. 139–154, Springer-Verlag, Sept. 1998.

  13. McAdam, B. J., “Generalising Techniques for Type Debugging,” inProc. of 1st Scottish Functional Programming Workshop, 1999.

  14. Milner, R., “A Theory of Type Polymorphism in Programming,”Journal of Computer and System Sciences, 17, pp. 348–375, 1978.

    Article  MATH  MathSciNet  Google Scholar 

  15. Odersky, M., Sulzmann, M. and Wehr, M., “Type Inference with Constrained Types,”Theory and Practice of Object Systems,5,1, 1999.

  16. Rémy, D., “Extending ML Type System with a Sorted Equational Theory,”Research Report 1766, Institut National de Recherche en Informatique et Automatisme, Rocquencourt, BP 105, 78 153 Le Chesnay Cedex, France, 1992.

    Google Scholar 

  17. Rideau, L. and Théry, L., “Interactive Programming Environment for ML,”Technical Report 3139, Institut National de Recherche en Informatique et en Automatique, Mar. 1997.

  18. Robinson, J. A., “A Machine-oriented Logic Based on the Resolution Principle,”Journal of ACM, 12, 1, pp. 23–41, Jan. 1965.

    Article  MATH  Google Scholar 

  19. The Standard ML of New Jersey, release 110.0.7. Bell Labs, Lucent Technologies, Sept. 2001. http://cm.bell-labs.com/cm/cs/what/smlnj.

  20. Sulzmann, M., “A General Type Inference Framework for Hindley/Milner Style Systems,” inProc. of 5th International Symposium on Functional and Logic Programming, Mar. 2001.

  21. Sulzmann, M., Müller, M. and Zenger, C., “Hindley/Milner Style Type Systems in Constraint Form,”Technical Report ACRC-99-009, University of South Australia, School of Computer and Information Science, Jul. 1999.

  22. Thatte, S. R., “Type Inference with Partial Types,”Theoretical Computer Science, 124, 1, pp. 127–148, Feb. 1994.

    Article  MATH  MathSciNet  Google Scholar 

  23. Wand, M., “Finding the Source of Type Errors,” inProc. of the 13th Annual ACM Symposium on Principles of Programming Languages, pp. 38–43, ACM Press, New York, 1986.

    Google Scholar 

  24. Yang, J., “Explaining Type Errors by Finding the Sources of Type Conflicts,” inProc. of 1st Scottish Functional Programming Workshop, pp. 387–401, Aug. 1999.

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hyunjun Eo.

Additional information

This work is supported by Creative Research Initiatives of the Korean Ministry of Science and Technology

National Creative Research Initiative Center, http://ropas.kaist.ac.kr

Work done while the third author was associated with Korea Advanced Institute of Science and Technology

Hyunjun Eo: He is a Ph.D. candidate in the Department of Computer Science at KAIST (Korea Advanced Institute of Science and Technology). He recieved his bachelor’s degree and master’s degree in Computer Science from KAIST in 1996 and 1998, respectively. His research interest has been on static program analysis, fixpoint iteration algorithm and higher-order and typed languages. From fall 1998, he has been a research assistant of the National Creative Research Initiative Center for Research on Program Analysis System. He is currently working on developing a tool for automatic generation of program analyzer.

Oukseh Lee: He is a Ph.D. candidate in the Department of Computer Science at KAIST (Korea Advanced Institute of Science and Technology). He received his bachelor’s and master’s degree in Computer Science from KAIST in 1995 and 1997, respectively. His research interest has been on static program analysis, type system, program language implementation, higher-order and typed languages, and program verification. From 1998, he has been a research assistant of the National Creative Research Initiative Center for Research on Program Analysis System. He is currently working on compile-time analyses and verification for the memory behavior of programs.

Kwangkeun Yi, Ph.D.: His research interest has been on semanticbased program analysis and systems application of language technologies. After his Ph.D. from University of Illinois at Urbana-Champaign he joined the Software Principles Research Department at Bell Laboratories, where he worked on various static analysis approaches for higher-order and typed programming languages. For 1995 to 2003 he was a faculty member in the Department of Computer Science, Korea Advanced Institute of Science and Technology. Since fall 2003, he has been a faculty member in the School of Computer Science and Engineering, Seoul National University.

About this article

Cite this article

Eo, H., Lee, O. & Yi, K. Proofs of a set of hybrid let-polymorphic type inference algorithms. New Gener Comput 22, 1–36 (2004). https://doi.org/10.1007/BF03037279

Download citation

  • Received:

  • Revised:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF03037279

Keywords

Navigation