Hostname: page-component-77f85d65b8-6c7dr Total loading time: 0 Render date: 2026-04-17T20:05:48.851Z Has data issue: false hasContentIssue false

Using types as search keys in function libraries

Published online by Cambridge University Press:  07 November 2008

Mikael Rittri
Affiliation:
Department of Computer Sciences, Chalmers University of Technology and University of Göteborg, Sweden
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 method is proposed to search for an identifier in a functional program library by using its Hindley–Milner type as a key. This can be seen as an approximation of using the specification as a key.

Functions that only differ in their argument order or currying are essentially the same, which is expressed by a congruence relation on types. During a library search, congruent types are identified. If a programmer is not satisfied with the type of a found value, he can use a conversion function (like curry), which must exist between congruent types, to convert the value into the type of his choice.

Types are congruent if they are isomorphic in all cartesian closed categories. To put it more simply, types are congruent if they are equal under an arithmetical interpretation, with cartesian product as multiplication and function space as exponentiation. This congruence relation is characterized by seven equational axioms. There is a simple term-rewriting algorithm to decide congruence, using which a search system has been implemented for the functional language Lazy ML, with good performance.

The congruence relation can also be used as a basis for other search strategies, e.g. searching for identifiers of a more general type, modulo congruence or allowing free type variables in queries.

Information

Type
Article
Copyright
Copyright © Cambridge University Press 1991
Submit a response

Discussions

No Discussions have been published for this article.