Design and Implementation of Deterministic Higher-order Patterns

Tetsuo Yokoyama,Zhenjiang Hu,Masato Takeichi
2005-01-01
Abstract:We introduce a class of deterministic higher-order patterns to Template Haskell for supporting declarative transformational pro- gramming with more elegant binding of pattern variables. Higher-order patterns are capable of checking and binding subtrees far from the root, which is useful for program manipulation. However, there are three ma- jor problems. First, it is dicult to explain why a particular desired matching result cannot be obtained because of the complicated higher- order matching algorithm. Second, the general higher-order matching al- gorithm is of high cost, which may be exponential time at worst. Third, the (possibly infinite) nondeterministic solutions of higher-order match- ing prevents it from being used in a functional setting. To resolve these problems, we impose reasonable restrictions on higher-order patterns to gain predictability, eciency and determinism. We show that our deter- ministic higher-order patterns are powerful to support concise specifica- tion and ecient implementation of various kinds of program transfor- mations for optimizations.
What problem does this paper attempt to address?