Abstract
Functional languages allow the definition of functions by pattern matching, which performs an analysis of the structure of values. However, the structures which can be described by such patterns are restricted to a fixed portion from the root of the value.
Context patterns are a new non-local form of patterns, which allow the matching of subterms without fixed distance from the root of the value. Typical applications of context patterns are functions which search a data structure for patterns and transform it by replacing the pattern. In this paper we introduce a new construct called extended context, which allows the definition of transformational functions without superfluous repetition of the recursive search. Furthermore, we present an inference system which formalises the type conditions for context patterns.
This is a preview of subscription content, log in via an institution.
Preview
Unable to display preview. Download preview PDF.
References
H. P. Barendregt. The Lambda Calculus: Its Syntax and Semantics, volume 103 of Studies in Logic and The Foundations of Mathematics. North-Holland, 1985.
P. Deransart and J. Małuszyński, editors. Proceedings of the 2nd International Workshop on Programming Language Implementation and Logic Programming (PLILP), number 456 in Lecture Notes in Computer Science. Springer-Verlag, 1990.
D. J. Dougherty and P. Johann. A Combinatory Approach to Higher-Order E-Unification. Theoretical Computer Science, 139(1–2): 207–242, March 1995.
M. Erwig. Active Patterns. In Kluge et.al. [12], pages 21—40.
C. Ferdinand. Pattern Matching in a Functional Transformational Language using Treeparsing. In Deransart and Małuszyński [2], pages 358–371.
W. D. Goldfarb. The Undecidability of the Second-Order Unification Problem. Theoretical Computer Science, 13(2): 225–230, February 1981.
R. Heckmann. A Functional Language for the Specification of Complex Tree Transformations. In H. Ganzinger, editor, Proceedings of the 2nd European Symposium on Programming (ESOP), number 300 in Lecture Notes in Computer Science, pages 175–190. Springer-Verlag, 1988.
P. Hudak, S. L. Peyton Jones, and P. Wadler et. al. Report on the Programming Language Haskell — A Non-strict, Purely Functional Language. ACM SIGPLAN Notices, 27(4), 1992.
G. Huet. A Unification Algorithm for Typed λ-Calculus. Theoretical Computer Science, 1: 27–57, 1975.
G. Huet and B. Lang. Proving and applying Program Transformations Expressed with Second Order Patterns. Acta Informatica, 11: 31–55, 1978.
R. J. M. Hughes. A Novel Representation of Lists and Its Application to the Function “reverse”, Information Processing Letters, 22(3): 141–144, March 1986.
W. Kluge et.al., editor. Selected Papers of the 8th International Workshop on Implementation of Functional Languages (IFL), number 1268 in Lecture Notes in Computer Science. Springer-Verlag, 1997.
M. Mohnen. Context Patterns in Haskell. In Kluge et.al. [12], pages 41–58.
M. Mohnen and S. Tobies. Implementing Context Patterns in the Glasgow Haskell Compiler. Technical Report AIB-97-04, RWTH Aachen, 1997.
S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, 1987.
C. Prehofer. Decidable Higher-order Unification Problems. In A. Bundy, editor, Proceedings of the 12th International Conference on Automated Deduction (CADE), number 814 in Lecture Notes in Computer Science, pages 635–649. Springer-Verlag, 1994.
C. Queinnec. Compilation of Non-Linear, Second Order Patterns on S-Expressions. In Deransart and Maluszynski [2], pages 340–357.
T. Sheard and L. Fegaras. A Fold for All Seasons. In Proceedings of the 6th Conference on Functional Programming Languages and Computer Architecture (FPCA), pages 233–242. ACM, September 1993.
W. Snyder and J. Gallier. Higher Order Unification Revisited: Complete Sets of Tranformations. Journal of Symbolic Computation, 8(1 & 2): 101–140, 1989. Special issue on unification. Part two.
V. F. Turchin. Program Transformation by Supercompilation. In H. Ganzinger and N. Jones, editors, Programs as Data Objects, number 217 in Lecture Notes in Computer Science, pages 257–281. Springer-Verlag, 1986.
P. Wadler. Views: A Way for Pattern-matching to Cohabit with Abstraction. In Proceedings of the 14th Symposium on Principles of Programming Languages (POPL), pages 307–313. ACM, January 1987.
R. Wilhelm. Tree Transformations, Functional Languages, and Attribute Grammars. In P. Deransart and M. Jourdan, editors, Attribute Grammars and their Applications, number 461 in LNCS, pages 116–129. Springer-Verlag, 1990.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1998 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Mohnen, M. (1998). Context patterns, part II. In: Clack, C., Hammond, K., Davie, T. (eds) Implementation of Functional Languages. IFL 1997. Lecture Notes in Computer Science, vol 1467. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0055440
Download citation
DOI: https://doi.org/10.1007/BFb0055440
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-64849-9
Online ISBN: 978-3-540-68528-9
eBook Packages: Springer Book Archive