Abstract
We investigate how to add coercive structural subtyping to a type system for simply-typed lambda calculus with Hindley-Milner polymorphism. Coercions allow to convert between different types, and their automatic insertion can greatly increase readability of terms. We present a type inference algorithm that, given a term without type information, computes a type assignment and determines at which positions in the term coercions have to be inserted to make it type-correct according to the standard Hindley-Milner system (without any subtypes). The algorithm is sound and, if the subtype relation on base types is a disjoint union of lattices, also complete. The algorithm has been implemented in the proof assistant Isabelle.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Benke, M.: Complexity of type reconstruction in programming languages with subtyping. Ph.D. thesis, Warsaw University (1997)
Bourdoncle, F., Merz, S.: On the integration of functional programming, class-based object-oriented programming, and multi-methods. Research Report 26, Centre de Mathématiques Appliquées, Ecole des Mines de Paris (March 1996)
Coq development team: The Coq proof assistant reference manual. INRIA (2010), http://coq.inria.fr version 8.3
Frey, A.: Satisfying subtype inequalities in polynomial space. Theor. Comput. Sci. 277(1-2), 105–117 (2002)
Fuh, Y.C., Mishra, P.: Type inference with subtypes. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300, pp. 94–114. Springer, Heidelberg (1988)
Luo, Z.: Coercions in a polymorphic type system. Mathematical Structures in Computer Science 18(4), 729–751 (2008)
Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)
Mitchell, J.C.: Coercion and type inference. In: POPL, pp. 175–185 (1984)
Mitchell, J.C.: Type inference with simple subtypes. J. Funct. Program. 1(3), 245–285 (1991)
Nipkow, T.: Order-sorted polymorphism in Isabelle. In: Huet, G., Plotkin, G. (eds.) Logical Environments, pp. 164–188. CUP (1993)
Nordlander, J.: Polymorphic subtyping in O’Haskell. Sci. Comput. Program. 43(2-3), 93–127 (2002)
Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)
Pottier, F.: Simplifying subtyping constraints: a theory. Information & Computation 170(2), 153–183 (2001)
Pratt, V.R., Tiuryn, J.: Satisfiability of inequalities in a poset. Fundam. Inform. 28(1-2), 165–182 (1996)
Saïbi, A.: Typing algorithm in type theory with inheritance. In: POPL, pp. 292–301 (1997)
Shields, M., Peyton Jones, S.: Object-oriented style overloading for Haskell. In: First Workshop on Multi-language Inferastructure and Interoperability (BABEL 2001), Firenze, Italy (September 2001)
Simonet, V.: Type Inference with Structural Subtyping: A Faithful Formalization of an Efficient Constraint Solver. In: Ohori, A. (ed.) APLAS 2003. LNCS, vol. 2895, pp. 283–302. Springer, Heidelberg (2003)
Tiuryn, J.: Subtype inequalities. In: LICS, pp. 308–315 (1992)
Traytel, D., Berghofer, S., Nipkow, T.: Extending Hindley-Milner type inference with coercive subtyping (long version) (2011), www.in.tum.de/~nipkow/pubs/coercions.pdf
Wand, M., O’Keefe, P.: On the complexity of type inference with coercion. In: FPCA 1989: Functional Programming Languages and Computer Architecture, pp. 293–298. ACM, New York (1989)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2011 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Traytel, D., Berghofer, S., Nipkow, T. (2011). Extending Hindley-Milner Type Inference with Coercive Structural Subtyping. In: Yang, H. (eds) Programming Languages and Systems. APLAS 2011. Lecture Notes in Computer Science, vol 7078. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-25318-8_10
Download citation
DOI: https://doi.org/10.1007/978-3-642-25318-8_10
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-25317-1
Online ISBN: 978-3-642-25318-8
eBook Packages: Computer ScienceComputer Science (R0)