Skip to main content

Extending Hindley-Milner Type Inference with Coercive Structural Subtyping

  • Conference paper
Programming Languages and Systems (APLAS 2011)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7078))

Included in the following conference series:

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.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Benke, M.: Complexity of type reconstruction in programming languages with subtyping. Ph.D. thesis, Warsaw University (1997)

    Google Scholar 

  2. 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)

    Google Scholar 

  3. Coq development team: The Coq proof assistant reference manual. INRIA (2010), http://coq.inria.fr version 8.3

  4. Frey, A.: Satisfying subtype inequalities in polynomial space. Theor. Comput. Sci. 277(1-2), 105–117 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  5. Fuh, Y.C., Mishra, P.: Type inference with subtypes. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300, pp. 94–114. Springer, Heidelberg (1988)

    Chapter  Google Scholar 

  6. Luo, Z.: Coercions in a polymorphic type system. Mathematical Structures in Computer Science 18(4), 729–751 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  7. Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  8. Mitchell, J.C.: Coercion and type inference. In: POPL, pp. 175–185 (1984)

    Google Scholar 

  9. Mitchell, J.C.: Type inference with simple subtypes. J. Funct. Program. 1(3), 245–285 (1991)

    Article  MathSciNet  MATH  Google Scholar 

  10. Nipkow, T.: Order-sorted polymorphism in Isabelle. In: Huet, G., Plotkin, G. (eds.) Logical Environments, pp. 164–188. CUP (1993)

    Google Scholar 

  11. Nordlander, J.: Polymorphic subtyping in O’Haskell. Sci. Comput. Program. 43(2-3), 93–127 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  12. Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)

    MATH  Google Scholar 

  13. Pottier, F.: Simplifying subtyping constraints: a theory. Information & Computation 170(2), 153–183 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  14. Pratt, V.R., Tiuryn, J.: Satisfiability of inequalities in a poset. Fundam. Inform. 28(1-2), 165–182 (1996)

    MathSciNet  MATH  Google Scholar 

  15. Saïbi, A.: Typing algorithm in type theory with inheritance. In: POPL, pp. 292–301 (1997)

    Google Scholar 

  16. 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)

    Google Scholar 

  17. 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)

    Chapter  Google Scholar 

  18. Tiuryn, J.: Subtype inequalities. In: LICS, pp. 308–315 (1992)

    Google Scholar 

  19. 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

  20. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics