skip to main content
research-article

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

Published:29 August 2015Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. O. Danvy and K. Millikin. Refunctionalization at work. Science of Computer Programming, 74(8):534–549, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. F. Pottier and N. Gauthier. Polymorphic typed defunctionalization and concretization. Higher-Order and Symbolic Computation, 19(1):125– 162, Mar. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of the ACM annual conference, pages 717– 740. ACM, 1972. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  16. P. Wadler. The expression problem. Note to Java Genericity mailing list, Nov. 1998.Google ScholarGoogle Scholar

Index Terms

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

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!