Abstract
As functional programmers, we are comfortable with the idea of mapping a function across the members of a list to obtain a new list of values. But there are very similar ways of mapping functions across other kinds of data structure, so what is special about lists? Why can’t we use the same name for each of these functions leaving the type system to determine which is appropriate in a particular situation? This is not just a matter of aesthetics or syntax since it would allow us to write general functions for any data structure that has an associated map function without having to repeat essentially the same definition in each case.
This paper describes a system of overloading based on the use of constructor classes — a natural generalization of type classes in Haskell — which provides a satisfactory solution to this problem and appears to have many other useful applications. We illustrate this with some examples using Wadler’s monadic style of programming, including the first concrete implementation of monad comprehensions known to us at the time of writing.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Kung Chen, Paul Hudak, and Martin Odersky (1992). Parametric type classes (Extended abstract). ACM conference on LISP and Functional Programming, San Francisco, California, June 1992.
Paul Hudak, Simon L. Peyton Jones and Philip Wadler (eds.) (1992). Report on the programming language Haskell, version 1.2. ACM SIGPLAN notices, 27, 5, May 1992.
Mark P. Jones (1992a) A theory of qualified types. In,nth European Symposium on Programming, Rennes, France, Springer Verlag LNCS 582, February 1992.
Mark P. Jones (1992b) Qualified types: Theory and practice. D.Phil. Thesis, Programming Research Group, Oxford University Computing Laboratory, July 1992.
Eugenio Moggi (1989). Computational lambda-calculus and monads. IEEE Symposium on Logic in Computer Science, Asilomar, California, June 1989.
Mike Spivey (1990). A functional theory of exceptions. Science of Computer Programming, 14(1), June 1990.
Philip Wadler and Stephen Blott (1989). How to make ad-hoc polymorphism less ad-hoc. In 16th ACMannual symposium on Principles of Programming Languages, Austin, Texas, January 1989.
Philip Wadler (1990). Comprehending Monads. ACM conference on LISP and Functional Programming, Nice, France, June 1990.
Philip Wadler (1992). The essence of functional programming. In 19th Annual Symposium on Principles of Programming Languages, Santa Fe, New Mexico, January 1992.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1993 British Computer Society
About this paper
Cite this paper
Jones, M.P. (1993). Programming with Constructor Classes (preliminary summary). In: Launchbury, J., Sansom, P. (eds) Functional Programming, Glasgow 1992. Workshops in Computing. Springer, London. https://doi.org/10.1007/978-1-4471-3215-8_11
Download citation
DOI: https://doi.org/10.1007/978-1-4471-3215-8_11
Publisher Name: Springer, London
Print ISBN: 978-3-540-19820-8
Online ISBN: 978-1-4471-3215-8
eBook Packages: Springer Book Archive