skip to main content
10.1145/2784731.2784763acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Automatic refunctionalization to a language with copattern matching: with applications to the expression problem

Published: 29 August 2015 Publication History

Abstract

Defunctionalization and refunctionalization establish a correspondence between first-class functions and pattern matching, but the correspondence is not symmetric: Not all uses of pattern matching can be automatically refunctionalized to uses of higher-order functions. To remedy this asymmetry, we generalize from first-class functions to arbitrary codata. This leads us to full defunctionalization and refunctionalization between a codata language based on copattern matching and a data language based on pattern matching. We observe how programs can be written as matrices so that they are modularly extensible in one dimension but not the other. In this representation, defunctionalization and refunctionalization correspond to matrix transposition which effectively changes the dimension of extensibility a program supports. This suggests applications to the expression problem.

References

[1]
A. Abel, B. Pientka, D. Thibodeau, and A. Setzer. Copatterns: Programming infinite structures by observations. In Proceedings of the Symposium on Principles of Programming Languages, pages 27–38. ACM, 2013.
[2]
M. S. Ager, D. Biernacki, O. Danvy, and J. Midtgaard. A functional correspondence between evaluators and abstract machines. In Proceedings of the Conference on Principles and Practice of Declarative Programming, pages 8–19. ACM, 2003.
[3]
U. B. Berger and H. Schwichtenberg. An inverse of the evaluation functional for typed λ–calculus. In Proceedings of the Symposium on Logic in Computer Science, pages 203–211. IEEE Computer Society, 1991.
[4]
J. Carette, O. Kiselyov, and C. Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(5):509–543, Sept. 2009.
[5]
W. R. Cook. Object-oriented programming versus abstract data types. In Proceedings of the REX Workshop / School on the Foundations of Object-Oriented Languages, pages 151–178. Springer-Verlag, 1990.
[6]
W. R. Cook. On understanding data abstraction, revisited. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages and Applications, pages 557–572. ACM, 2009.
[7]
O. Danvy and K. Millikin. Refunctionalization at work. Science of Computer Programming, 74(8):534–549, 2009.
[8]
O. Danvy and L. R. Nielsen. Defunctionalization at work. In Proceedings of the Conference on Principles and Practice of Declarative Programming, pages 162–174, 2001.
[9]
P. Hudak. Modular domain specific languages and tools. In Proceedings of the Conference on Software Reuse, pages 134–142. IEEE Computer Society, June 1998.
[10]
D. Janzen and K. de Volder. Programming with crosscutting effective views. In Proceedings of the European Conference on Object-Oriented Programming, pages 195–218. Springer LNCS 3086, 2004.
[11]
R. Lämmel and O. Rypacek. The Expression Lemma. In Proceedings of the Conference on Mathematics of Program Construction. Springer LNCS 5133, July 2008.
[12]
F. Pottier and N. Gauthier. Polymorphic typed defunctionalization and concretization. Higher-Order and Symbolic Computation, 19(1):125– 162, Mar. 2006.
[13]
J. C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of the ACM annual conference, pages 717– 740. ACM, 1972.
[14]
J. C. Reynolds. User-defined types and procedural data structures as complementary approaches to data abstraction. In New Directions in Algorithmic Languages 1975, pages 157–168. IFIP Working Group 2.1 on Algol, INRIA, 1975.
[15]
A. Setzer, A. Abel, B. Pientka, and D. Thibodeau. Unnesting of copatterns. In Proceedings of the Joint Conference on Rewriting Techniques and Applications and Typed Lambda Calculi and Applications, pages 31–45. Springer LNCS 8560, 2014.
[16]
P. Wadler. The expression problem. Note to Java Genericity mailing list, Nov. 1998.

Cited By

View all
  • (2024)Deriving Dependently-Typed OOP from First PrinciplesProceedings of the ACM on Programming Languages10.1145/36498468:OOPSLA1(983-1009)Online publication date: 29-Apr-2024
  • (2023)Exact Recursive Probabilistic ProgrammingProceedings of the ACM on Programming Languages10.1145/35860507:OOPSLA1(665-695)Online publication date: 6-Apr-2023
  • (2022)Introduction and elimination, left and rightProceedings of the ACM on Programming Languages10.1145/35476376:ICFP(438-465)Online publication date: 31-Aug-2022
  • Show More Cited By

Index Terms

  1. Automatic refunctionalization to a language with copattern matching: with applications to the expression problem

        Recommendations

        Comments

        Information & Contributors

        Information

        Published In

        cover image ACM Conferences
        ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
        August 2015
        436 pages
        ISBN:9781450336697
        DOI:10.1145/2784731
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 50, Issue 9
          ICFP '15
          September 2015
          436 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2858949
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

        Sponsors

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        Published: 29 August 2015

        Permissions

        Request permissions for this article.

        Check for updates

        Author Tags

        1. Codata
        2. Copattern Matching
        3. Defunctionalization
        4. Expression Problem
        5. Refunctionalization
        6. Uroboro

        Qualifiers

        • Research-article

        Conference

        ICFP'15
        Sponsor:

        Acceptance Rates

        Overall Acceptance Rate 333 of 1,064 submissions, 31%

        Upcoming Conference

        ICFP '25
        ACM SIGPLAN International Conference on Functional Programming
        October 12 - 18, 2025
        Singapore , Singapore

        Contributors

        Other Metrics

        Bibliometrics & Citations

        Bibliometrics

        Article Metrics

        • Downloads (Last 12 months)12
        • Downloads (Last 6 weeks)3
        Reflects downloads up to 13 Dec 2024

        Other Metrics

        Citations

        Cited By

        View all
        • (2024)Deriving Dependently-Typed OOP from First PrinciplesProceedings of the ACM on Programming Languages10.1145/36498468:OOPSLA1(983-1009)Online publication date: 29-Apr-2024
        • (2023)Exact Recursive Probabilistic ProgrammingProceedings of the ACM on Programming Languages10.1145/35860507:OOPSLA1(665-695)Online publication date: 6-Apr-2023
        • (2022)Introduction and elimination, left and rightProceedings of the ACM on Programming Languages10.1145/35476376:ICFP(438-465)Online publication date: 31-Aug-2022
        • (2022)Structural refinement typesProceedings of the 7th ACM SIGPLAN International Workshop on Type-Driven Development10.1145/3546196.3550163(15-27)Online publication date: 6-Sep-2022
        • (2019)Decomposition diversity with symmetric data and codataProceedings of the ACM on Programming Languages10.1145/33710984:POPL(1-28)Online publication date: 20-Dec-2019
        • (2018)Dualizing Generalized Algebraic Data Types by Matrix TranspositionProgramming Languages and Systems10.1007/978-3-319-89884-1_3(60-85)Online publication date: 14-Apr-2018

        View Options

        Login options

        View options

        PDF

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        Media

        Figures

        Other

        Tables

        Share

        Share

        Share this Publication link

        Share on social media