@MISC{Mitchell_derivinggeneric, author = {Neil Mitchell}, title = {Deriving Generic Functions by Example}, year = {} }
Bookmark
OpenURL
Abstract
Abstract. A function is said to be generic if it operates over values of any data type. For example, a generic equality function can test pairs of booleans, integers, lists, trees etc. In most languages programmers must define generic functions multiple times, specialised for each data type. Alternatively, a tool could be used to specify the relationship between the data type and the implementation, but this relationship may be complex. This paper describes a solution: given a single example of the generic function on one data type, we can infer the relationship between a data type and the implementation. We have used our method in the Derive tool, allowing the implementation of 60 % of the generic functions to be inferred. 1