Affiliation:
1. Microsoft Research, Cambridge, U.K.
2. Queensland University of Technology, Brisbane, Australia
Abstract
Pattern matching of algebraic data types (ADTs) is a standard feature in typed functional programming languages, but it is well known that it interacts poorly with abstraction. While several partial solutions to this problem have been proposed, few have been implemented or used. This paper describes an extension to the .NET language F# called
active patterns
, which supports pattern matching over abstract representations of generic heterogeneous data such as XML and term structures, including where these are represented via object models in other .NET languages. Our design is the first to incorporate both ad hoc pattern matching functions for partial decompositions and "views" for total decompositions, and yet remains a simple and lightweight extension. We give a description of the language extension along with numerous motivating examples. Finally we describe how this feature would interact with other reasonable and related language extensions: existential types quantified at data discrimination tags, GADTs, and monadic generalizations of pattern matching.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
11 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Unboxed Data Constructors: Or, How cpp Decides a Halting Problem;Proceedings of the ACM on Programming Languages;2024-01-05
2. Rhombus: A New Spin on Macros without All the Parentheses;Proceedings of the ACM on Programming Languages;2023-10-16
3. Polymorphic extractors for semantic and portable pattern matching (short paper);Proceedings of the 18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences;2019-10-21
4. Pattern synonyms;ACM SIGPLAN Notices;2018-07-19
5. Non-linear Pattern Matching with Backtracking for Non-free Data Types;Programming Languages and Systems;2018