Skip to main content

Type Classes are Signatures of Abstract Types

  • Conference paper
Book cover Declarative Programming, Sasbachwalden 1991

Part of the book series: Workshops in Computing ((WORKSHOPS COMP.))

  • 35 Accesses

Abstract

We present an extension of Haskell’s type class concept in which a type class is identified with the signature of an abstract type As shown by Mitchell and Plotkin, abstract types can be expressed using existential quantification. Unlike in Mitchell and Plotkin’s work, an abstract type does not come with one — and only one — implementation. Rather, any concrete type can be declared to be an implementation by a clause that corresponds to an instance declaration in Haskell. We introduce F-bounded existential quantification, where an abstract type has the form:

$$\exists \alpha .C(\alpha ).\tau (\alpha ).$$

Here, C(α) is a set of constraints that restricts the range of the bound variable α, and τ(α) is a type constructed from α. The expression reads “some type τ(α), where α is some arbitrary fixed type satisfying constraints C(α)”. The constraint set C corresponds to a type class. Just like a type class, it contains declarations for overloaded identifiers as well as conformity clauses that declare one abstract type to be more specific than another.

The generalization of type classes to abstract types has the advantage of greater expressiveness: We can model polymorphic abstract types and heterogeneous data structures, concepts which cannot be expressed in Haskell. An example of a polymorphic abstract type is ∀α.Bag α, the abstract type of all bags with elements of type α. In Haskell, we would either have to fix the element type, or we would have to fix the implementation of Bag.

Our extension shares the desirable properties of the type class approach in that it is fully static and in that type reconstruction is feasible.

Supported by the Defense Advanced Research Projects Agency/Information Systems Technology Office under the Office of Naval Research contract N00014-90-J-1110

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

Access this chapter

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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. P. Canning, W. Cook, W. Hill, W. Olthoff, and J. Mitchell. F-bounded polymorphism for object-oriented programming. In Proc. Functional Programming and Computer Architecture, pages 273–280, 1989.

    Google Scholar 

  2. L. Cardelli. Basic polymorphic typechecking. Science of Computer Programming, 9 (8): 147–172, 1987.

    Article  Google Scholar 

  3. L. Cardelli and P. Wegner. On understanding types, data abstraction and polymorphism. ACM Computing Surveys, 17 (4): 471–522, Dec. 1985.

    Google Scholar 

  4. W. Cook. A proposal for making Eiffel type-safe. Computer Journal,32(4):305311, 1989.

    Google Scholar 

  5. G. Cormack and A. Wright. Type-dependent parameter inference. In Proc. SIGPLAN’90 Conf. on Programming Language Design and Implementation, pages 127–136, White Plains, NY, June 1990.

    Google Scholar 

  6. L. Damas and R. Milner. Principal type schemes for functional programs. In Proc. 9th Annual ACM Symp. on Principles of Programming Languages, pages 207–212, Jan. 1982.

    Google Scholar 

  7. F. Henglein and H. Mairson. The complexity of type inference for higher-order typed lambda calculi. In Proc. 18th ACM Symp. on Principles of Programming Languages (POPL), Orlando, Florida, Jan. 1991.

    Google Scholar 

  8. S. Kaes. Parametric overloading in polymorphic programming languages. In H. Ganzinger, editor, Proc. 2nd European Symosium on Programming, Lecture Notes in Computer Science, Vol. 300, pages 131–144, Nancy, France, March 1988. Springer-Verlag.

    Google Scholar 

  9. K. Läufer and M. Odersky. Type inference for an object-oriented extension of ML. NYU-CIMS Report, New York University, Department of Computer Science, in preparation.

    Google Scholar 

  10. D. MacQueen. Using dependent types to express modular structure. In Proc. 13th ACM Symp. on Principles of Programming Languages, pages 277–286. ACM, Jan. 1986.

    Google Scholar 

  11. R. Milner. A theory of type polymorphism in programming. J. Computer and System Sciences, 17: 348–375, 1978.

    Article  MATH  MathSciNet  Google Scholar 

  12. R. Milner, M. Tofte., and R. Harper. The Definition of Standard ML. MIT Press, 1990.

    Google Scholar 

  13. J. Mitchell, S. Meldal, and N. Madhay. An extension of Standard ML modules with subtyping and inheritance. In Proc. ACM Symp. on Principles of Programming LanguagesJan. 1991.

    Google Scholar 

  14. J. Mitchell and G. Plotkin. Abstract Types have Existential Type. InProc. 12th ACM Symp. on Principles of Programming Languagespages 37–51. ACM, Jan. 1985.

    Google Scholar 

  15. T. Niphow and G. Snelting. Type classes and overloading resolution via order-sorted unification. Technical Report PI-R8/90, Technische Hochschule Darmstadt, Praktische Informatik, July 1990.

    Google Scholar 

  16. J. Palsberg and M. Schwartzbach. Type substitution for object-oriented programming. In N. Meyrowitz, editor,Proc. Conf. Object-Oriented Programming: Systems Languages and Applications and European Conf. on Object-Oriented Programmingpages 151–160, Ottawa, Canada, Oct. 1990. ACM Press.

    Google Scholar 

  17. D. Sandberg. An alternative to subclassing. In Proc. Object-Oriented Programming: Languages, Systems and Applications, pages 424–428, 1986.

    Google Scholar 

  18. S. Thatte. Type inference with partial types. In Proc. Intl Conf. on Algorithms, Languages and Programming, pages 615–629, 1988.

    Google Scholar 

  19. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In Proc. 16th Annual ACM Symp. on Principles of Programming Languages,pages 6076. ACM, Jan. 1989.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1992 Springer-Verlag London

About this paper

Cite this paper

Läufer, K., Odersky, M. (1992). Type Classes are Signatures of Abstract Types. In: Darlington, J., Dietrich, R. (eds) Declarative Programming, Sasbachwalden 1991. Workshops in Computing. Springer, London. https://doi.org/10.1007/978-1-4471-3794-8_10

Download citation

  • DOI: https://doi.org/10.1007/978-1-4471-3794-8_10

  • Publisher Name: Springer, London

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

  • Online ISBN: 978-1-4471-3794-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics