Adam is a PhD student at the University of St Andrews, studying under Prof. Kevin Hammond and Dr. Christopher Brown. His research interests lie in programming language design and implementation, with a focus on program transformation, static analysis techniques, and parallelism. He has worked on the ParaPhrase project and currently on the RePhrase project, both 3-year EU research projects that aim to develop new refactoring technology targeting heterogeneous parallel architectures.
Refactoring is the process of improving the internal structure of a program without changing its external behaviour. Structural changes can range from renaming functions or moving functions between modules, to the introduction of design patterns and the elimination of code clones. In functional languages, higher-order functions enable simple and easily understood abstractions, and can be used to implement recursion schemes, i.e. patterns that traverse over data structures whose behaviour are well understood. Map and fold are common examples. Principally used in clone detection and elimination transformations, anti-unification finds the least general generalisation of two functions or terms, which can then be implemented as a higher-order function and used to avoid code reuse. As a general technique, anti-unification can be used to detect recursion scheme instances in programs. In this paper, we present a technique that detects instances of recursion schemes in Haskell 98 functions. We have implemented our approach in the Haskell refactoring tool HaRe, and demonstrate our technique on a range of examples, including functions inspired by the Haskell Prelude.Slides