Skip to main content

Principal Type Inference for GHC-Style Multi-parameter Type Classes

  • Conference paper

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

Abstract

We observe that the combination of multi-parameter type classes with existential types and type annotations leads to a loss of principal types and undecidability of type inference. This may be a surprising fact for users of these popular features. We conduct a concise investigation of the problem and are able to give a type inference procedure which, if successful, computes principal types under the conditions imposed by the Glasgow Haskell Compiler (GHC). Our results provide new insights on how to perform type inference for advanced type extensions.

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

Buying options

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

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Damas, L., Milner, R.: Principal type-schemes for functional programs. In: Proc. of POPL 1982, pp. 207–212. ACM Press, New York (1982)

    Google Scholar 

  2. Demoen, B., la de Banda, M.G., Harvey, W., Marriott, K., Stuckey, P.J.: An overview of HAL. In: Jaffar, J. (ed.) CP 1999. LNCS, vol. 1713, pp. 174–189. Springer, Heidelberg (1999)

    Google Scholar 

  3. Faxén, K.F.: Haskell and principal types. In: Proc. of Haskell Workshop 2003, pp. 88–97. ACM Press, New York (2003)

    Chapter  Google Scholar 

  4. Frühwirth, T.: Constraint Handling Rules. In: Podelski, A. (ed.) Constraint Programming: Basics and Trends. LNCS, vol. 910. Springer, Heidelberg (1995)

    Google Scholar 

  5. Glasgow haskell compiler home page, http://www.haskell.org/ghc/

  6. Hall, C.V., Hammond, K., Peyton Jones, S.L., Wadler, P.L.: Type classes in Haskell. ACM Transactions on Programming Languages and Systems 18(2), 109–138 (1996)

    Article  Google Scholar 

  7. Henderson, F., et al.: The Mercury language reference manual (2001), http://www.cs.mu.oz.au/research/mercury/

  8. Henglein, F.: Type inference with polymorphic recursion. Transactions on Programming Languages and Systems 15(1), 253–289 (1993)

    Article  Google Scholar 

  9. Hugs home page, haskell.cs.yale.edu/hugs/

  10. Jeffery, D., Henderson, F., Somogyi, Z.: Type classes in Mercury. In: Edwards, J. (ed.) Proc. Twenty-Third Australasian Computer Science Conf. Australian Computer Science Communications, vol. 22, pp. 128–135. IEEE Computer Society Press, Los Alamitos (2000)

    Google Scholar 

  11. Jones, M.P.: Coherence for qualified types. Research Report YALEU/DCS/RR-989, Yale University, Department of Computer Science (September 1993)

    Google Scholar 

  12. Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 230. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  13. Peyton Jones, S., Jones, M.P., Meijer, E.: Type classes: an exploration of the design space. In: Haskell Workshop (June 1997)

    Google Scholar 

  14. Kuncak, V., Rinard, M.: Structural subtyping of non-recursive types is decidable. In: Proc. of LICS 2003, pp. 96–107. IEEE Computer Society Press, Los Alamitos (2003)

    Google Scholar 

  15. Lassez, J., Maher, M., Marriott, K.: Unification revisited. In: Foundations of Deductive Databases and Logic Programming. Morgan Kaufmann, San Francisco (1987)

    Google Scholar 

  16. Läufer, K.: Type classes with existential types. Journal of Functional Programming 6(3), 485–517 (1996)

    Article  MATH  MathSciNet  Google Scholar 

  17. Läufer, K., Odersky, M.: Polymorphic type inference and abstract data types. ACM Trans. Program. Lang. Syst. 16(5), 1411–1430 (1994)

    Article  Google Scholar 

  18. Miller, D.: Unification under a mixed prefix. J. Symb. Comput. 14(4), 321–358 (1992)

    Article  MATH  Google Scholar 

  19. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)

    Article  MATH  MathSciNet  Google Scholar 

  20. Odersky, M., Läufer, K.: Putting type annotations to work. In: Proc. of POPL 1996, pp. 54–67. ACM Press, New York (1996)

    Chapter  Google Scholar 

  21. Peyton Jones, S. (ed.): Haskell 1998 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)

    Google Scholar 

  22. Plasmeijer, M.J., van Eekelen, M.C.J.D.: Language report Concurrent Clean. Technical Report CSI-R9816, Computing Science Institute. University of Nijmegen, Nijmegen, The Netherlands (June 1998), ftp://ftp.cs.kun.nl/pub/Clean/Clean13/doc/refman13.ps.gz

  23. Shoenfield, J.R.: Mathematical Logic. Addison-Wesley, Reading (1967)

    MATH  Google Scholar 

  24. Stuckey, P.J., Sulzmann, M.: A theory of overloading. ACM Transactions on Programming Languages and Systems (TOPLAS) 27(6), 1–54 (2005)

    Article  Google Scholar 

  25. Sulzmann, M., Duck, G.J., Peyton Jones, S., Stuckey, P.J.: Understanding functional dependencies via Constraint Handling Rules. Journal of Functional Programming (to appear, 2006)

    Google Scholar 

  26. Sulzmann, M., Schrijvers, T., Stuckey, P.J.: Principal type inference for GHC-style multi-parameter type classes. Technical report, The National University of Singapore (2006)

    Google Scholar 

  27. Sulzmann, M., Wazny, J., Stuckey, P.J.: A framework for extended algebraic data types. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 47–64. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2006 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Sulzmann, M., Schrijvers, T., Stuckey, P.J. (2006). Principal Type Inference for GHC-Style Multi-parameter Type Classes. In: Kobayashi, N. (eds) Programming Languages and Systems. APLAS 2006. Lecture Notes in Computer Science, vol 4279. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11924661_2

Download citation

  • DOI: https://doi.org/10.1007/11924661_2

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-48937-5

  • Online ISBN: 978-3-540-48938-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics