Hostname: page-component-7c8c6479df-ph5wq Total loading time: 0 Render date: 2024-03-19T13:59:31.567Z Has data issue: false hasContentIssue false

HM(X) type inference is CLP(X) solving

Published online by Cambridge University Press:  01 March 2008

MARTIN SULZMANN
Affiliation:
School of Computing, National University of Singapore, S16 Level 5, 3 Science Drive 2, Singapore 117543, Singapore (e-mail: sulzmann@comp.nus.edu.sg)
PETER J. STUCKEY
Affiliation:
NICTA Victoria Laboratory, Department of Computer Science and Software Engineering, University of Melbourne, Victoria 3010, Australia (e-mail: pjs@cs.mu.oz.au)
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.

The HM(X) system is a generalization of the Hindley/Milner system parameterized in the constraint domain X. Type inference is performed by generating constraints out of the program text, which are then solved by the domain-specific constraint solver X. The solver has to be invoked at the latest when type inference reaches a let node so that we can build a polymorphic type. A typical example of such an inference approach is Milner's algorithm W. We formalize an inference approach where the HM(X) type inference problem is first mapped to a CLP(X) program. The actual type inference is achieved by executing the CLP(X) program. Such an inference approach supports the uniform construction of type inference algorithms and has important practical consequences when it comes to reporting type errors. The CLP(X) style inference system, where X is defined by Constraint Handling Rules, is implemented as part of the Chameleon system.

Type
Articles
Copyright
Copyright © Cambridge University Press 2007

References

Aiken, A. & Wimmers, E. L. (1992) Solving systems of set constraints. In Seventh IEEE Symposium on Logic in Computer Science, Santa Cruz, CA. Los Alamitos, CA: IEEE Computer Society Press, pp. 320340.Google Scholar
Alves, S. & Florido, M. (2002) Type inference using constraint handling rules. Electr. Notes Theor. Comput. Sci. 64.Google Scholar
Birkedal, L. & Tofte, M. (2001) A constraint-based region inference algorithm. Theor. Comput. Sci. 258 (1–2), 299392.Google Scholar
Coquery, E. & Fages, F. (2002) TCLP: Overloading, subtyping and parametric polymorphism made practical for CLP. In Proc. of ICLP '02, vol. 2401. Berlin: Springer-Verlag.Google Scholar
Damas, L. & Milner, R. (1982) Principal type-schemes for functional programs. In Proc. of POPL'82. New York: ACM Press, pp. 207212.Google Scholar
Demoen, B., Garcíade la Banda, M. de la Banda, M. & Stuckey, P. J. (1999) Type constraint solving for parametric and ad-hoc polymorphism. In Proc. of the 22nd Australian Computer Science Conference. Berlin: Springer-Verlag, pp. 217228.Google Scholar
Dietzen, S. & Pfenning, F. (1991) A declarative alternative to “assert'' in logic programming. In Proc. of ISLP'91, pp. 372–386.Google Scholar
Eo, H., Lee, O. & Yi, K. (2003) Proofs of a set of hybrid let-polymorphic type inference algorithms. New Generation Comput. 22 (1), 136.Google Scholar
Fordan, A. & Yap, R. H. C. (1998) Early projection in CLP(R). In CP'98: Proceedings of the 4th International Conference on Principles and Practice of Constraint Programming. London, UK: Springer-Verlag, pp. 177191.Google Scholar
Frühwirth, T. (1995) Constraint handling rules. In Constraint Programming: Basics and Trends. LNCS. Berlin: Springer-Verlag, pp. 90107.Google Scholar
Fuh, Y.-C. & Mishra, P. (1990) Type inference with subtypes. Theor. Comput. Sci. 73, 155175.Google Scholar
Glynn, K., Stuckey, P. J. & Sulzmann, M. (2000) Type classes and constraint handling rules. In Workshop on Rule-Based Constraint Reasoning and Programming. Available at: http://xxx.lanl.gov/abs/cs.PL/0006034. Accessed August 2007.Google Scholar
Henglein, F. (1992) Simple Closure Analysis. DIKU Semantics Report D-193. University of Copenhagen.Google Scholar
Henglein, F. (1993) Type inference with polymorphic recursion. Trans. Programming Lang Syst. 15 (1), 253289.Google Scholar
Henkin, L., Monk, J. D. & Tarski, A. (1971) Cylindric Algebra. Amsterdam: North-Holland Publishing Company.Google Scholar
Jaffar, J. & Lassez, J-L. (1987) Constraint logic programming. In Proc. of POPL'87, pp. 111–119.Google Scholar
Jaffar, J., Maher, M., Marriott, K. & Stuckey, P.J. (1998) The semantics of constraint logic programs. J. Logic Programming 37 (1–3), 146.Google Scholar
Kanellakis, P. C., Mairson, H. G. & Mitchell, J. C. (1991) Unification and ML-type reconstruction. In Computational logic-Essays in Honor of Alan Robinson. Cambridge, Mass.: MIT Press, pp. 444478.Google Scholar
Kennedy, A. J. (1996) Type Inference and Equational Theories. Tech. rept. LIX/RR/96/09. LIX, Ecole Polytechnique, 91128 Palaiseau Cedex, France.Google Scholar
Lakshman, T. L. & Reddy, U S. (1991) Typed Prolog: A semantic reconstruction of the Mycroft-O'Keefe type system. In Proc. of ISLP'91. Cambridge, Mass.: MIT Press, pp. 202217.Google Scholar
Lee, O. & Yi, K. (1998) Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Programming Lang. Syst., 20 (4), 707723.Google Scholar
Liang, C. (1997) Let-polymorphism and eager type schemes. In TAPSOFT '97: Proceedings of the 7th International Joint Conference CAAP/FASE on Theory and Practice of Software Development. Springer-Verlag, pp. 490–501.Google Scholar
Maher, M. (1988) Complete axiomatizations of the algebras of finite, rational and infinite trees. In Proc. 3rd Logic in Computer Science Conference, pp. 348–357.Google Scholar
McAllester, D. A. (2003) Joint RTA-TLCA invited talk: A logical algorithm for ML type inference. In Proc. of RTA'03. LNCS, Vol. 2706. Berlin: Springer-Verlag, pp. 436451.Google Scholar
Milner, R. (1978) A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 348375.Google Scholar
Mitchell, J. (2002) Concepts of Programming Languages. Cambridge University Press.Google Scholar
Müller, M. (1994) A constraint-based recast of ML-polymorphism. In 8th International Workshop on Unification. Also available as Technical Report 94-R-43, Université de Nancy.Google Scholar
Mycroft, A. & O'Keefe, R. (1984) A polymorphic type system for Prolog. Artif. Intelligence 23, 295307.Google Scholar
Nadathur, G. & Miller, D. (1988) An overview of λprolog. In Fifth International Conference and Symposium on Logic Programming, Bowen, K. & Kowalski, R. (eds). MIT Press.Google Scholar
Odersky, M., Sulzmann, M. & Wehr, M. (1999) Type inference with constrained types. Theory Pract. Object Syst., 5 (1), 3555.Google Scholar
Palsberg, J. & Smith, S. (1996) Constrained types and their expressiveness. ACM Trans. Programming Lang. Syst. 18 (5), 519527.Google Scholar
PeytonJones, S. Jones, S. (ed). (2003) Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press.Google Scholar
Pottier, F. (1998) A framework for type inference with subtyping. In Proc. of ICFP'98. ACM Press, pp. 228238.Google Scholar
Pottier, F. & Rémy, D. (2005) The essence of ML type inference. Advanced Topics in Types and Programming Languages, Pierce, B. C. (ed). Cambridge, Mass.: MIT Press, Chap. 10, pp. 389489.Google Scholar
Rémy, D. (1993) Type inference for records in a natural extension of ML. In Theoretical Aspects of Object-Oriented Programming. Types, Semantics and Language Design, Chapter 3. Gunter, C. A. & Mitchell, J. C. (eds), MIT Press.Google Scholar
Robinson, J. A. (1965) A machine-oriented logic based on the resolution principle. J. ACM 12, 2341.Google Scholar
Stuckey, P. J. & Sulzmann, M. (2005) A theory of overloading. ACM Trans. Programming Lang. syst. (TOPLAS) 27 (6), 154.Google Scholar
Stuckey, P. J., Sulzmann, M. & Wazny, J. (2003a) The Chameleon type debugger. In Proc. of Fifth International Workshop on Automated Debugging (AADEBUG 2003). Computer Research Repository. Available at: http://www.acm.org/corr/.Google Scholar
Stuckey, P. J., Sulzmann, M. & Wazny, J. (2003b) Interactive type debugging in Haskell. In Proc. of Haskell'03. New York: ACM Press, pp. 7283.Google Scholar
Stuckey, P. J., Sulzmann, M. & Wazny, J. (2004) Improving type error diagnosis. In Proc. of Haskell'04. New York: ACM Press, pp. 8091.Google Scholar
Stuckey, P. J., Sulzmann, M. & Wazny, J. (2006) Type processing by constraint reasoning. Proc. of APLAS'06. LNCS, Vol. 4279, Berlin: Springer-Verlag, pp. 1–25.Google Scholar
Sulzmann, M. (2000) A General Framework for Hindley/Milner Type Systems With Constraints. Ph.D. thesis, Department of Computer Science, Yale University.Google Scholar
Sulzmann, M. (2001) A general type inference framework for Hindley/Milner style systems. In Proc. of FLOPS'01. LNCS, Vol. 2024. Berlin: Springer-Verlag, pp. 246–263.Google Scholar
Sulzmann, M., Müller, M. & Zenger, C. (1999) Hindley/Milner Style Type Systems in Constraint Form. Research Report ACRC-99-009. University of South Australia, School of Computer and Information Science.Google Scholar
Sulzmann, M., Odersky, M. & Wehr, M. (1997) Type inference with constrained types. In FOOL4: 4th Int. Workshop on Foundations of Object-Oriented Programming Languages.Google Scholar
Sulzmann, M. & Wazny, J. (2007) Chameleon. Available at http://www.comp.nus.edu.sg~sulzmann/chameleon. Accessed August 2007.Google Scholar
Urban, C., Pitts, A. M. & Gabbay, M. J. (2004) Nominal unification. Theor. Comput. Sci. 323 (1-3), 473497.Google Scholar
Wadler, P. & Blott, S. (1989) How to make ad-hoc polymorphism less ad-hoc. In Proc. of POPL '89. New York: ACM Press, pp. 6076.Google Scholar
Zenger, C. (1999) Indizierte Typen. Ph.D. thesis, Universität Karlsruhe, Germany.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.