Gradual Refinement

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 of invertible programming, we propose an approach to abstract datatypes based on a right-invertible language RINV--every function has a right (or pre-) inverse. We show how this new design is able to permit a smooth incremental transition from programs with algebraic datatypes and pattern matching, to ones with proper encapsulation (implemented as abstract datatypes), while maintaining simple and sound reasoning.

[1]  Etienne Morel,et al.  Global optimization by suppression of partial redundancies , 1979, CACM.

[2]  Simon J. Thompson,et al.  Lawful Functions and Program Verification in Miranda , 1990, Sci. Comput. Program..

[3]  Mark Tullsen,et al.  First Class Patterns , 2000, PADL.

[4]  Sjaak Smetsers,et al.  Optimizing Generic Functions , 2004, MPC.

[5]  Damien Sereni,et al.  Termination analysis and call graph construction for higher-order functional programs , 2007, ICFP '07.

[6]  C. Barry Jay,et al.  The pattern calculus , 2004, TOPL.

[7]  Martin Odersky,et al.  Matching Objects with Patterns , 2007, ECOOP.

[8]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[9]  John Hughes,et al.  Generalising monads to arrows , 2000, Sci. Comput. Program..

[10]  Marko C. J. D. van Eekelen,et al.  There and back again: arrows for invertible programming , 2005, Haskell '05.

[11]  Nate Foster,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[12]  Martin Erwig,et al.  Active Patterns , 1996, Implementation of Functional Languages.

[13]  Shin-Cheng Mu,et al.  A programmable editor for developing structured documents based on bidirectional transformations , 2004, PEPM '04.

[14]  Maarten M. Fokkinga,et al.  Program Calculation Properties of Continuous Algebras , 1991 .

[15]  Ricardo Peña-Marí,et al.  A new look at pattern matching in abstract data types , 1996, ICFP '96.

[16]  Guy L. Steele,et al.  Organizing functional code for parallel execution or, foldl and foldr considered slightly harmful , 2009, ICFP.

[17]  Johan Jeuring,et al.  Optimizing generics is easy! , 2010, PEPM '10.

[18]  Shin-Cheng Mu,et al.  An Injective Language for Reversible Computation , 2004, MPC.

[19]  Richard S. Bird The promotion and accumulation strategies in transformational programming , 1984, TOPL.

[20]  Stephen N. Zilles,et al.  Programming with abstract data types , 1974 .

[21]  Rod M. Burstall,et al.  HOPE: An experimental applicative language , 1980, LISP Conference.

[22]  Giuseppe Castagna,et al.  Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types , 2008, JACM.

[23]  Lambert Meertens,et al.  Algorithmics : towards programming as a mathematical activity , 1986 .

[24]  Richard S. Bird,et al.  An introduction to the theory of lists , 1987 .

[25]  Clare E. Martin,et al.  Disciplined, efficient, generalised folds for nested datatypes , 2004, Formal Aspects of Computing.

[26]  Juan José Moreno-Navarro,et al.  Bialgebra views: a way for polytypic programming to cohabit with data abstraction , 2008, WGP '08.

[27]  Richard S. Bird,et al.  A calculus of functions for program derivation , 1990 .

[28]  Simon L. Peyton Jones,et al.  Pattern Guards and Transformational Patterns , 2000, Electron. Notes Theor. Comput. Sci..

[29]  Don Syme,et al.  Extensible pattern matching via a lightweight language extension , 2007, ICFP '07.

[30]  M. R. Sleep,et al.  A short note concerning lazy reduction rules for append , 1982 .

[31]  Philip Wadler,et al.  Views: a way for pattern matching to cohabit with data abstraction , 1987, POPL '87.

[32]  Benjamin C. Pierce,et al.  Boomerang: resourceful lenses for string data , 2008, POPL '08.

[33]  Christophe Ringeissen,et al.  A Pattern Matching Compiler for Multiple Target Languages , 2003, CC.

[34]  Akimasa Morihata,et al.  Automatic inversion generates divide-and-conquer parallel programs , 2007, PLDI '07.

[35]  Philip Wadler,et al.  A critique of Abelson and Sussman or why calculating is better than scheming , 1987, SIGP.

[36]  F. Warren Burton,et al.  Pattern matching with abstract data types , 1993, Journal of Functional Programming.

[37]  Chris Okasaki Views for Standard ML , 2011 .

[38]  Benjamin C. Pierce,et al.  Quotient lenses , 2008, ICFP 2008.

[39]  Neil D. Jones,et al.  The size-change principle for program termination , 2001, POPL '01.

[40]  Benjamin C. Pierce,et al.  Updatable Security Views , 2009, 2009 22nd IEEE Computer Security Foundations Symposium.

[41]  Barbara Liskov,et al.  Program Development in Java - Abstraction, Specification, and Object-Oriented Design , 1986 .

[42]  Shin-Cheng Mu,et al.  An Algebraic Approach to Bi-directional Updating , 2004, APLAS.