Infinite data structures are elegantly defined by means of copattern matching, a dual construction to pattern matching that expresses the outcomes of the observations of an infinite structure. In the paper the OCaml programming language is extended with copatterns, exploiting the duality between pattern matching and copattern matching. Provided that a functional programming language has GADTs, every copattern matching can be transformed into a pattern matching viaa purely local syntactic transformation, a macro. The development of this extension leads to a generalization of previous calculus of copatterns: the introduction of first-class observation queries.
Paul Laforgue, Yann Régis-Gianas. Copattern matching and first-class observations in OCaml, with a macro // PPDP-17.
Presenter: Dmitry Kosarev
Date: February 19, 2018
Venue: room 3248, Faculty of Mathematics and Mechanics, Saint Petersburg State University, Stary Peterhof, Universitetski pr., 28