Using types as search keys in function libraries
Mikael Rittri · Journal of Functional Programming · 1991
Abstract 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.
Cited by 78 works. doi:10.1017/s095679680000006x Open-access PDF
Authors
References
- Lecture Notes in Computer Science 1205
- Lecture Notes in Artificial Intelligence
- Fast Probabilistic Algorithms for Verification of Polynomial Identities
- Principal type-schemes for functional programs
- To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus, and Formalism
- Miranda: A non-strict functional language with polymorphic types
- Complete Sets of Reductions for Some Equational Theories
- Combinators and Functional Programming Languages
- Determining the Equivalence of Algebraic Expressions by Hash Coding
- Unification theory