Using types as search keys in function libraries
- 1 January 1991
- journal article
- research article
- Published by Cambridge University Press (CUP) in Journal of Functional Programming
- Vol. 1 (1) , 71-89
- https://doi.org/10.1017/s095679680000006x
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.Keywords
This publication has 17 references indexed in Scilit:
- Coherence and valid isomorphism in closed categories applications of proof theory to category theory in a computer sclentist perspectivePublished by Springer Nature ,2005
- Unification theoryJournal of Symbolic Computation, 1989
- The Chalmers Lazy-ML CompilerThe Computer Journal, 1989
- Provable isomorphisms and domain equations in models of typed languagesPublished by Association for Computing Machinery (ACM) ,1985
- Miranda: A non-strict functional language with polymorphic typesLecture Notes in Computer Science, 1985
- Determining equivalence of expressions in random polynomial timePublished by Association for Computing Machinery (ACM) ,1984
- The category of finite sets and Cartesian closed categoriesJournal of Mathematical Sciences, 1983
- Principal type-schemes for functional programsPublished by Association for Computing Machinery (ACM) ,1982
- Fast Probabilistic Algorithms for Verification of Polynomial IdentitiesJournal of the ACM, 1980
- Determining the Equivalence of Algebraic Expressions by Hash CodingJournal of the ACM, 1971