Type Classes with Functional Dependencies

  • Mark P. Jones
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1782)


Type classes in Haskell allow programmers to define functions that can be used on a set of different types, with a potentially different implementation in each case. For example, type classes are used to support equality and numeric types, and for monadic programming. A commonly requested extension to support ‘multiple parameters’ allows a more general interpretation of classes as relations on types, and has many potentially useful applications. Unfortunately, many of these examples do not work well in practice, leading to ambiguities and inaccuracies in inferred types and delaying the detection of type errors.

This paper illustrates the kind of problems that can occur with multiple parameter type classes, and explains how they can be resolved by allowing programmers to specify explicit dependencies between the parameters. A particular novelty of this paper is the application of ideas from the theory of relational databases to the design of type systems.


Relational Database Functional Dependency Type Variable Type Class Parameter Class 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. [1]
    W. W. Armstrong. Dependency structures of data base relationships. In IFIP Cong., Geneva, Switzerland, 1974.Google Scholar
  2. [2]
    S. M. Blott. An approach to overloading with polymorphism. PhD thesis, Department of Computing Science, University of Glasgow, September 1991.Google Scholar
  3. [3]
    K. Chen, P. Hudak, and M. Odersky. Parametric type classes (extended abstract). In ACM conference on LISP and Functional Programming, San Francisco, CA, June 1992.Google Scholar
  4. [4]
    M. P. Jones. Qualified Types: Theory and Practice. PhD thesis, Programming Research Group, Oxford University Computing Laboratory, July 1992. Published by Cambridge University Press, November 1994.Google Scholar
  5. [5]
    M. P. Jones. Simplifying and improving qualified types. In International Conference on Functional Programming Languages and Computer Architecture, pages 160–169, June 1995.Google Scholar
  6. [6]
    M. P. Jones. A system of constructor classes: overloading and implicit higher-order polymorphism. Journal of Functional Programming, 5(1), January 1995.Google Scholar
  7. [7]
    M. P. Jones and J. C. Peterson. Hugs 98 User Manual, September 1999.Google Scholar
  8. [8]
    D. Maier. The Theory of Relational Databases. Computer Science Press, 1983.Google Scholar
  9. [9]
    C. Okasaki. Edison User’s Guide, May 1999.Google Scholar
  10. [10]
    S. Peyton Jones. Bulk types with class. In Proceedings of the Second Haskell Workshop, Amsterdam, June 1997.Google Scholar
  11. [11]
    S. Peyton Jones and J. Hughes, editors. Report on the Programming Language Haskell 98, A Non-strict Purely Functional Language, February 1999.Google Scholar
  12. [12]
    S. Peyton Jones and J. Hughes (editors). Standard libraries for the Haskell 98 programming language, February 1999.Google Scholar
  13. [13]
    S. Peyton Jones, M. Jones, and E. Meijer. Type classes: Exploring the design space. In Proceedings of the Second Haskell Workshop, Amsterdam, June 1997.Google Scholar
  14. [14]
    P. Wadler and S. Blott. How to make ad hoc polymorphism less ad hoc. In Proceedings of 16th ACM Symposium on Principles of Programming Languages, pages 60–76, Jan 1989.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • Mark P. Jones
    • 1
  1. 1.Department of Computer Science and EngineeringOregon Graduate Institute of Science and TechnologyBeavertonUSA

Personalised recommendations