ABSTRACT
This paper presents type classes, a new approach to ad-hoc polymorphism. Type classes permit overloading of arithmetic operators such as multiplication, and generalise the “eqtype variables” of Standard ML. Type classes extend the Hindley/Milner polymorphic type system, and provide a new approach to issues that arise in object-oriented programming, bounded type quantification, and abstract data types. This paper provides an informal introduction to type classes, and defines them formally by means of type inference rules.
- BEJ88.D. BjOrner, A. Ershov, and N.D. Jones, editors, Partial Evaluation and Mixed Computation, North-Holland, 1988 (to appear).]] Google ScholarDigital Library
- CW85.L. Cardelli and P. Wegner, On understanding types, data abstraction, and polymorphism. Computing Surveys 17, 4, December 1985.]] Google ScholarDigital Library
- Car88.L. Cardelli, Structural subtyping and the notion of power type. In Proceedings of ~he 15'th Annual Symposium on Principles of Programming Languages, San Diego, California, January 1988.]] Google ScholarDigital Library
- DM82.L. Damns and R. Milner, Principal type schemes for functional programs. In Proceedings of the 9'th Annual Symposium on Principles of Programming Languages, Albuquerque, N.M., January 1982.]] Google ScholarDigital Library
- FGJM85.K. Futasagi, J.A. Goguen, J.-P. Jouannaud, and J. Meseguer, Principles of OBJ2. In Proceedings of the 12'~h Annual Symposium on Principles of Programming Languages, January 1985.]] Google ScholarDigital Library
- GR83.A. Goldberg and D. Robsort, Smalltalk- 80: The Language and its Implementation. Addison-Wesley, 1983.]] Google ScholarDigital Library
- Hin69.R. Hindley, The principal type scheme of an object in combinatory logic. Trans. Am. Math. Soc. 146, pp. 29-60, December 1969.]]Google Scholar
- HMM86.R. Harper, D. MacQueen, and R. Milner, Standard ML. Report ECS-LFCS-86-2, Edinburgh University, Computer Science Dept., 1986.]]Google Scholar
- HMT88.R. Harper, R. Milner, and M. Tofte, The definition of Standard ML, version 2. Report ECS-LFCS-88-62, Edinburgh University, Computer Science Dept., 1988.]]Google ScholarDigital Library
- Kae88.S. Kaes, Parametric polymorphism. In Proceedings of the 2'nd European Symposium on Programming, Nancy, France, March 1988. LNCS 300, Springer-Verlag, 1988.]]Google Scholar
- Mil78.R. Milner, A theory of type polymorphism in programming. J. Compul. Syst. Sci. 17, pp. 348-375, 1978.]]Google ScholarCross Ref
- Mil84.R. Milner, A proposal for Standard ML. In Proceedings of lhe Symposium on Lisp and Functional Programming, Austin, Texas, August 1984.]] Google ScholarDigital Library
- Mil87.R. Milner, Ch~nges to the Standard ML core language. Report ECS-LFCS-87-33, Edinburgh University, Computer Science Dept., 1987.]]Google Scholar
- MP85.J.C. Mitchell and G. D. Plotkin, Abstract types have existential type. In Proceedings of ~he 12'th Annual Symposium on Principles of Programming Languages, Jartuary 1985.]] Google ScholarDigital Library
- Rey85.J.C. Reynolds, Three approaches to type structure. In Mathematical Foundations of Software Development, LNCS 185, Springer-Verlag, 1985.]] Google ScholarDigital Library
- Str67.C. Strachey, Fundamental concepts in programming languages. Lecture notes for International Summer School in Computer Programming, Copenhagen, August 1967.]]Google Scholar
- Tur85.D.A. Turner, Miranda: A non-strict functional language with polymorphic types. In Proceedings of the #'nd lurernational Conference on Functional Programming Languages and Computer Architecture, Nancy, France, September 1985. LNCS 201, Springer-Verlag, 1985.]] Google ScholarDigital Library
- Wan87.M. Wand, Complete type inference for simple objects. In Proceedings of the Symposium on Logic in Computer Science, Ithaca, NY, June 1987. IEEE Computer Society Press, 1987.]]Google Scholar
Index Terms
- How to make ad-hoc polymorphism less ad hoc
Recommendations
Ad-hoc polymorphism and dynamic typing in a statically typed functional language
WGP '10: Proceedings of the 6th ACM SIGPLAN workshop on Generic programmingStatic typing in functional programming languages such as Clean, Haskell, and ML is highly beneficial: it prevents erroneous behaviour at run time and provides opportunities for optimisations. However, dynamic typing is just as important as sometimes ...
Partial type constructors: or, making ad hoc datatypes less ad hoc
Functional programming languages assume that type constructors are total. Yet functional programmers know better: counterexamples range from container types that make limiting assumptions about their contents (e.g., requiring computable equality or ...
Comments