Plaid: Pattern Language for Abstract Datatypes
نویسندگان
چکیده
The expressiveness of traditional syntactic pattern matching is severely limited by its lack of abstraction. Because syntax patterns are mired in the builtin types understood by the pattern matching system, they lack the ability to express patterns over abstract data types (ADT’s). More advanced pattern matching techniques, such as semantic matching, can overcome this, but at the per-ADT cost of the complex code required to add new pattern combinators to the system. Plaid defines a new pattern language that captures a strict subset of Scheme capable of both regular computation, as well as reverse computation. This allows it to overcome both the limitations of syntactic patterns and the cost of semantic patterns by providing a means by which programmers can write a single specification of the mapping between the abstract and concrete representations of an ADT that simultaneously serves as constructor, predicate, accessor, and pattern combinator for that ADT. This specification is written virtually identically to how a regular constructor would be written. Furthermore, the Plaid pattern language is capable of capturing non-determinism and decisions within pattern matching, thus admitting a very broad interpretation of what can be considered an ADT constructor. This leads to variety of interesting capabilities, such as the ability to view concrete data in multiple abstract ways, the ability to canonicalize multiple concrete representations in one abstract way, and the ability to imagine more convenient representations of existing data.
منابع مشابه
Gradual Refinement Blending Pattern Matching with Data Abstraction
Pattern matching is advantageous for understanding and reasoning about function definitions, but it tends to tightly couple the interface and implementation of a datatype. Significant effort has been invested in tackling this loss of modularity; however, decoupling patterns from concrete representations while maintaining soundness of reasoning has been a challenge. Inspired by the development o...
متن کاملRelating Abstract Datatypes and Z-Schemata
In this paper we investigate formally the relationship between the notion of abstract datatypes in an arbitrary institution, found in algebraic specification languages like Clear, ASL, and CASL; and the notion of schemata from the model-oriented specification language Z. To this end the institution S of the logic underlying Z is defined, and a translation of Z-schemata to abstract datatypes ove...
متن کاملDependently Typed Pattern Matching
The mechanism for declaring datatypes to model data structures in functional programming languages such as Standard ML and Haskell can offer both convenience in programming and clarity in code. With the introduction of dependent datatypes in DML, the programmer can model data structures with more accuracy, thus capturing more program invariants. In this paper, we study some practical aspects of...
متن کاملAn E cient Implementation of Plaid
State is central to understanding objects in the real world a moving car is very di erent from a parked car. Yet most object-oriented languages provide no native support for state or state change. The Plaid language introduces a new object model in which objects are not only instances of a class, but can also be in mutable states. In Plaid, a car object can have one abstract state for driving a...
متن کاملInput and Output Application Programming Interface for Plaid Standard Library
Object oriented (OO) is the most accepted object modeling languages nowadays. Although OO languages are successful in modeling real world entities, nevertheless, there is little to no support for modeling state of object precisely in code. To overcome this problem, a new general purpose programming language is proposed that is built on two paradigms which are typestate-oriented and permission-b...
متن کامل