Hostname: page-component-586b7cd67f-t7fkt Total loading time: 0 Render date: 2024-11-22T05:11:57.283Z Has data issue: false hasContentIssue false

Generics for the masses

Published online by Cambridge University Press:  10 August 2006

RALF HINZE
Affiliation:
Institut für Informatik III, Universität Bonn, Römerstraße 164, 53117 Bonn, Germany (email: [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

A generic function is a function that can be instantiated on many data types to obtain data type specific functionality. Examples of generic functions are the functions that can be derived in Haskell, such as show, read, and ‘==’. The recent years have seen a number of proposals that support the definition of generic functions. Some of the proposals define new languages, some define extensions to existing languages. As a common characteristic none of the proposals can be made to work within Haskell 98: they all require something extra, either a more sophisticated type system or an additional language construct. The purpose of this paper is to show that one can, in fact, program generically within Haskell 98 obviating to some extent the need for fancy type systems or separate tools. Haskell's type classes are at the heart of this approach: they ensure that generic functions can be defined succinctly and, in particular, that they can be used painlessly. We detail three different implementations of generics both from a practical and from a theoretical perspective.

Type
Article
Copyright
2006 Cambridge University Press
Submit a response

Discussions

No Discussions have been published for this article.