skip to main content
research-article

Applicative bidirectional programming with lenses

Published:29 August 2015Publication History
Skip Abstract Section

Abstract

A bidirectional transformation is a pair of mappings between source and view data objects, one in each direction. When the view is modified, the source is updated accordingly with respect to some laws. One way to reduce the development and maintenance effort of bidirectional transformations is to have specialized languages in which the resulting programs are bidirectional by construction---giving rise to the paradigm of bidirectional programming. In this paper, we develop a framework for applicative-style and higher-order bidirectional programming, in which we can write bidirectional transformations as unidirectional programs in standard functional languages, opening up access to the bundle of language features previously only available to conventional unidirectional languages. Our framework essentially bridges two very different approaches of bidirectional programming, namely the lens framework and Voigtländer's semantic bidirectionalization, creating a new programming style that is able to bag benefits from both.

References

  1. F. Bancilhon and N. Spyratos. Update semantics of relational views. ACM Trans. Database Syst., 6(4):557–575, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. M. J. Barbosa, J. Cretin, N. Foster, M. Greenberg, and B. C. Pierce. Matching lenses: alignment and view update. In P. Hudak and S. Weirich, editors, ICFP, pages 193–204. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. R. S. Bird, J. Gibbons, S. Mehner, J. Voigtländer, and T. Schrijvers. Understanding idiomatic traversals backwards and forwards. In C. chieh Shan, editor, Haskell, pages 25–36. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Bohannon, J. N. Foster, B. C. Pierce, A. Pilkiewicz, and A. Schmitt. Boomerang: resourceful lenses for string data. In G. C. Necula and P. Wadler, editors, POPL, pages 407–419. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. A. Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In J. Hook and P. Thiemann, editors, ICFP, pages 143–156. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. U. Dayal and P. A. Bernstein. On the correct translation of update operations on relational views. ACM Trans. Database Syst., 7(3):381– 416, 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. T. Ellis. Category and lenses, Sep 2012.Google ScholarGoogle Scholar
  8. Blog post: http://web.jaguarpaw.co.uk/~tom/blog/posts/ 2012-09-30-category-and-lenses.html.Google ScholarGoogle Scholar
  9. L. Fegaras. Propagating updates through XML views using lineage tracing. In F. Li, M. M. Moro, S. Ghandeharizadeh, J. R. Haritsa, G. Weikum, M. J. Carey, F. Casati, E. Y. Chang, I. Manolescu, S. Mehrotra, U. Dayal, and V. J. Tsotras, editors, ICDE, pages 309–320. IEEE, 2010.Google ScholarGoogle Scholar
  10. J. N. Foster, M. B. Greenwald, J. T. Moore, B. C. Pierce, and A. Schmitt. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst., 29(3), 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. N. Foster, A. Pilkiewicz, and B. C. Pierce. Quotient lenses. In J. Hook and P. Thiemann, editors, ICFP, pages 383–396. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. N. Foster, K. Matsuda, and J. Voigtländer. Three complementary approaches to bidirectional programming. In J. Gibbons, editor, SSGIP, volume 7470 of Lecture Notes in Computer Science, pages 1–46. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Y. Hayashi, D. Liu, K. Emoto, K. Matsuda, Z. Hu, and M. Takeichi. A web service architecture for bidirectional XML updating. In G. Dong, X. Lin, W. Wang, Y. Yang, and J. X. Yu, editors, APWeb/WAIM, volume 4505 of Lecture Notes in Computer Science, pages 721–732. Springer, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. S. J. Hegner. Foundations of canonical update support for closed database views. In S. Abiteboul and P. C. Kanellakis, editors, ICDT, volume 470 of Lecture Notes in Computer Science, pages 422–436. Springer, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Hidaka, Z. Hu, K. Inaba, H. Kato, K. Matsuda, and K. Nakano. Bidirectionalizing graph transformations. In P. Hudak and S. Weirich, editors, ICFP, pages 205–216. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Hofmann, B. C. Pierce, and D. Wagner. Symmetric lenses. In T. Ball and M. Sagiv, editors, POPL, pages 371–384. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Z. Hu, S.-C. Mu, and M. Takeichi. A programmable editor for developing structured documents based on bidirectional transformations. In N. Heintze and P. Sestoft, editors, PEPM, pages 178–189. ACM, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. Jaskelioff and R. O’Connor. A representation theorem for secondorder functionals. CoRR, abs/1402.1699, 2014.Google ScholarGoogle Scholar
  19. S. Lindley, P. Wadler, and J. Yallop. Idioms are oblivious, arrows are meticulous, monads are promiscuous. Electr. Notes Theor. Comput. Sci., 229(5):97–117, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Mac Lane. Categories for the Working Mathematician, volume 5 of Graduate Texts in Matheematics. Springer, second edition edition, 1998.Google ScholarGoogle Scholar
  21. K. Matsuda, Z. Hu, K. Nakano, M. Hamana, and M. Takeichi. Bidirectionalization transformation based on automatic derivation of view complement functions. In R. Hinze and N. Ramsey, editors, ICFP, pages 47–58. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. K. Matsuda and M. Wang. Bidirectionalization for free with runtime recording: or, a light-weight approach to the view-update problem. In R. Peña and T. Schrijvers, editors, PPDP, pages 297–308. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. K. Matsuda and M. Wang. “Bidirectionalization for free” for monomorphic transformations. Science of Computer Programming, 2014. DOI: 10.1016/j.scico.2014.07.008.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. C. McBride and R. Paterson. Applicative programming with effects. J. Funct. Program., 18(1):1–13, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. B. Milewski. Lenses, Stores, and Yoneda, Oct 2013.Google ScholarGoogle Scholar
  26. blog post: http://bartoszmilewski.com/2013/10/08/ lenses-stores-and-yoneda/.Google ScholarGoogle Scholar
  27. S.-C. Mu, Z. Hu, and M. Takeichi. An algebraic approach to bidirectional updating. In W.-N. Chin, editor, APLAS, volume 3302 of Lecture Notes in Computer Science, pages 2–20. Springer, 2004.Google ScholarGoogle Scholar
  28. R. O’Connor. Functor is to lens as applicative is to biplate: Introducing multiplate. CoRR, abs/1103.2841, 2011. Accepted in WGP’11, but not included in its proceedings. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. H. Pacheco, Z. Hu, and S. Fischer. Monadic combinators for "putback" style bidirectional programming. In W.-N. Chin and J. Hage, editors, PEPM, pages 39–50. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. R. Paterson. A new notation for arrows. In B. C. Pierce, editor, ICFP, pages 229–240. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. R. Paterson. Constructing applicative functors. In J. Gibbons and P. Nogueira, editors, MPC, volume 7342 of Lecture Notes in Computer Science, pages 300–323. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. R. Rajkumar, S. Lindley, N. Foster, and J. Cheney. Lenses for web data. In Preliminary Proceedings of Second International Workshop on Bidirectional Transformations (BX 2013), 2013.Google ScholarGoogle Scholar
  33. J. C. Reynolds. Types, abstraction and parametric polymorphism. In R. Mason, editor, Information Processing, pages 513–523. Elsevier Science Publishers B.V. (North-Holland), 1983.Google ScholarGoogle Scholar
  34. T. van Laarhoven. Cps based functional references, Jul 2009.Google ScholarGoogle Scholar
  35. blog post: http://www.twanvl.nl/blog/haskell/ cps-functional-references.Google ScholarGoogle Scholar
  36. J. Voigtländer. Bidirectionalization for free! (pearl). In Z. Shao and B. C. Pierce, editors, POPL, pages 165–176. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. J. Voigtländer. Free theorems involving type constructor classes: functional pearl. In G. Hutton and A. P. Tolmach, editors, ICFP, pages 173–184. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. J. Voigtländer, Z. Hu, K. Matsuda, and M. Wang. Combining syntactic and semantic bidirectionalization. In P. Hudak and S. Weirich, editors, ICFP, pages 181–192. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. J. Voigtländer, Z. Hu, K. Matsuda, and M. Wang. Enhancing semantic bidirectionalization via shape bidirectionalizer plug-ins. J. Funct. Program., 23(5):515–551, 2013.Google ScholarGoogle ScholarCross RefCross Ref
  40. P. Wadler. Theorems for free! In FPCA, pages 347–359, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. M. Wang, J. Gibbons, K. Matsuda, and Z. Hu. Gradual refinement: Blending pattern matching with data abstraction. In C. Bolduc, J. Desharnais, and B. Ktari, editors, MPC, volume 6120 of Lecture Notes in Computer Science, pages 397–425. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. M. Wang, J. Gibbons, K. Matsuda, and Z. Hu. Refactoring pattern matching. Sci. Comput. Program., 78(11):2216–2242, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. M. Wang, J. Gibbons, and N. Wu. Incremental updates for efficient bidirectional transformations. In M. M. T. Chakravarty, Z. Hu, and O. Danvy, editors, ICFP, pages 392–403. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. M. Wang and S. Najd. Semantic bidirectionalization revisited. In W.-N. Chin and J. Hage, editors, PEPM, pages 51–62. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Y. Xiong, D. Liu, Z. Hu, H. Zhao, M. Takeichi, and H. Mei. Towards automatic model synchronization from model transformations. In R. E. K. Stirewalt, A. Egyed, and B. Fischer, editors, ASE, pages 164– 173. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Y. Yu, Y. Lin, Z. Hu, S. Hidaka, H. Kato, and L. Montrieux. Maintaining invariant traceability through bidirectional transformations. In M. Glinz, G. C. Murphy, and M. Pezzè, editors, ICSE, pages 540–550. IEEE, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Applicative bidirectional programming with lenses

      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

      • Published in

        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
        • 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

        Copyright © 2015 ACM

        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].

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 29 August 2015

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader