Abstract
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.
The research reported in this paper was supported by the USAF Air Materiel Command, contract # F19628-96-C-0161.
Chapter PDF
Similar content being viewed by others
Keywords
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.
References
W. W. Armstrong. Dependency structures of data base relationships. In IFIP Cong., Geneva, Switzerland, 1974.
S. M. Blott. An approach to overloading with polymorphism. PhD thesis, Department of Computing Science, University of Glasgow, September 1991.
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.
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.
M. P. Jones. Simplifying and improving qualified types. In International Conference on Functional Programming Languages and Computer Architecture, pages 160–169, June 1995.
M. P. Jones. A system of constructor classes: overloading and implicit higher-order polymorphism. Journal of Functional Programming, 5(1), January 1995.
M. P. Jones and J. C. Peterson. Hugs 98 User Manual, September 1999.
D. Maier. The Theory of Relational Databases. Computer Science Press, 1983.
C. Okasaki. Edison User’s Guide, May 1999.
S. Peyton Jones. Bulk types with class. In Proceedings of the Second Haskell Workshop, Amsterdam, June 1997.
S. Peyton Jones and J. Hughes, editors. Report on the Programming Language Haskell 98, A Non-strict Purely Functional Language, February 1999.
S. Peyton Jones and J. Hughes (editors). Standard libraries for the Haskell 98 programming language, February 1999.
S. Peyton Jones, M. Jones, and E. Meijer. Type classes: Exploring the design space. In Proceedings of the Second Haskell Workshop, Amsterdam, June 1997.
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.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2000 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Jones, M.P. (2000). Type Classes with Functional Dependencies. In: Smolka, G. (eds) Programming Languages and Systems. ESOP 2000. Lecture Notes in Computer Science, vol 1782. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-46425-5_15
Download citation
DOI: https://doi.org/10.1007/3-540-46425-5_15
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-67262-3
Online ISBN: 978-3-540-46425-9
eBook Packages: Springer Book Archive