The pattern calculus is a new foundation for computation, in which the expressive power of functions and of data structures are combined within pattern-matching functions. The best existing foundations focus on either functions, as in the lambda-calculus, or on data structures, as in Turing machines, or on compromises involving both, as in object-orientation. By contrast, a small typed pattern calculus is able to support all the main programming styles, including functional, imperative, object-oriented and query-based styles, and there is evidence that it can support a language for Web services, able to exploit data structures about which almost nothing is known. The book is divided into three parts, on terms, types and programs, and contains many new results. Part I introduces static and then dynamic pattern calculus. The former supports path polymorphic functions, able to traverse arbitrary paths through data structures. It also shows how Lisp is more than just lambda-calculus. The dynamic calculus allows any term to be a pattern, so that patterns can be discovered, combined and simplified on the fly. Part II supportsa family of type systems for pattern calculi that build on novel typings of lambda-calculus. The type system for query calculus allows database queries to be applied uniformly to arbitrary data structures, while still guaranteeing that evaluation terminates. Subtyping and type parameters combine to produce type inequalities, whose solutions provide an expressive account of object-orientation. Also, typing can be made implicit, which simplifies implementation. Part III realises all these ideas in a new programming language, bondi, where the various programming styles can be combined, including algebraic data types and object-oriented classes. This book is useful for researchers with an interest in the foundations of computing, programming language design, the integration of existing programming styles, or the development of new programming styles. The reader is supported throughout with proofs and examples, both in text and in bondi, the source code of which is freely available online.
Cited By
- Jay B Typed Program Analysis without Encodings Proceedings of the 2025 ACM SIGPLAN International Workshop on Partial Evaluation and Program Manipulation, (54-65)
- Jay B A simpler lambda calculus Proceedings of the 2019 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, (1-9)
- Broman D and Siek J Gradually typed symbolic expressions Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, (15-29)
- Viso A, Bonelli E and Ayala-Rincón M (2016). Type Soundness for Path Polymorphism, Electronic Notes in Theoretical Computer Science (ENTCS), 323:C, (235-251), Online publication date: 11-Jul-2016.
- Roberts M and Sloane A Type inference for the spine view of data Proceedings of the 10th ACM SIGPLAN workshop on Generic programming, (25-34)
- Solodkyy Y, Dos Reis G and Stroustrup B (2013). Open pattern matching for C++, ACM SIGPLAN Notices, 49:3, (33-42), Online publication date: 5-Mar-2014.
- Solodkyy Y, Dos Reis G and Stroustrup B Open pattern matching for C++ Proceedings of the 12th international conference on Generative programming: concepts & experiences, (33-42)
- Given-Wilson T, Huang F and Jay B Multi-polymorphic programming in bondi Proceedings of the 9th ACM SIGPLAN workshop on Generic programming, (53-60)
- Petit B (2012). Continuation Models for the Lambda Calculus With Constructors, Electronic Notes in Theoretical Computer Science (ENTCS), 286, (337-350), Online publication date: 1-Sep-2012.
- Carette J and Stump A Towards typing for small-step direct reflection Proceedings of the ACM SIGPLAN 2012 workshop on Partial evaluation and program manipulation, (93-96)
- Jay B and Palsberg J Typed self-interpretation by pattern matching Proceedings of the 16th ACM SIGPLAN international conference on Functional programming, (247-258)
- Jay B and Palsberg J (2011). Typed self-interpretation by pattern matching, ACM SIGPLAN Notices, 46:9, (247-258), Online publication date: 18-Sep-2011.
- Balabonski T Optimality for dynamic patterns Proceedings of the 12th international ACM SIGPLAN symposium on Principles and practice of declarative programming, (231-242)
Index Terms
- Pattern Calculus: Computing with Functions and Structures
Recommendations
The pattern calculus
There is a significant class of operations such as mapping that are common to all data structures. The goal of generic programming is to support these operations on arbitrary data types without having to recode for each new type. The pattern calculus ...
A Typed Pattern Calculus
The theory of programming with pattern-matching function definitions has been studied mainly in the framework of first-order rewrite systems. We present a typed functional calculus that emphasizes the strong connection between the structures of whole ...
Label dependent lambda calculus and gradual typing
Dependently-typed programming languages are gaining importance, because they can guarantee a wide range of properties at compile time. Their use in practice is often hampered because programmers have to provide very precise types. Gradual typing is a ...