Skip to main content

Generic Point-free Lenses

  • Conference paper
Mathematics of Program Construction (MPC 2010)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 6120))

Included in the following conference series:

Abstract

Lenses are one the most popular approaches to define bidirectional transformations between data models. A bidirectional transformation with view-update, denoted a lens, encompasses the definition of a forward transformation projecting concrete models into abstract views, together with a backward transformation instructing how to translate an abstract view to an update over concrete models. In this paper we show that most of the standard point-free combinators can be lifted to lenses with suitable backward semantics, allowing us to use the point-free style to define powerful bidirectional transformations by composition. We also demonstrate how to define generic lenses over arbitrary inductive data types by lifting standard recursion patterns, like folds or unfolds. To exemplify the power of this approach, we “lensify” some standard functions over naturals and lists, which are tricky to define directly “by-hand” using explicit recursion.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Backhouse, R., Doornbos, H.: Mathematics of recursive program construction. Manuscript (2001), http://www.cs.nott.ac.uk/rcb/MPC/papers

  2. Backus, J.: Can programming be liberated from the von Neumann style? a functional style and its algebra of programs. Communications of the ACM 21(8), 613–641 (1978)

    Article  MATH  MathSciNet  Google Scholar 

  3. Bancilhon, F., Spyratos, N.: Update semantics of relational views. ACM Transactions on Database Systems 6(4), 557–575 (1981)

    Article  MATH  Google Scholar 

  4. Berdaguer, P., Cunha, A., Pacheco, H., Visser, J.: Coupled schema transformation and data: Conversion for XML and SQL. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 290–304. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  5. Bird, R., de Moor, O.: The Algebra of Programming. Prentice-Hall, Englewood Cliffs (1997)

    Google Scholar 

  6. Bohannon, A., Foster, J.N., Pierce, B.C., Pilkiewicz, A., Schmitt, A.: Boomerang: resourceful lenses for string data. In: Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’08), pp. 407–419. ACM, New York (2008)

    Google Scholar 

  7. Bohannon, A., Pierce, B.C., Vaughan, J.A.: Relational lenses: a language for updatable views. In: Proceedings of the 25th ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems (PODS’06), pp. 338–347. ACM, New York (2006)

    Google Scholar 

  8. Capretta, V., Uustalu, T., Vene, V.: Recursive coalgebras from comonads. Information and Computation 204(4), 437–468 (2006)

    Article  MATH  MathSciNet  Google Scholar 

  9. Cunha, A., Oliveira, J.N., Visser, J.: Type-safe two-level data transformation. In: Misra, J., Nipkow, T., Sekerinski, E. (eds.) FM 2006. LNCS, vol. 4085, pp. 284–299. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  10. Cunha, A., Pacheco, H.: Algebraic specialization of generic functions for recursive types. In: Proceedings of the 2nd Workshop on Mathematically Structured Functional Programming (MSFP’08). ENTCS, Elsevier Science Publishers B. V., Amsterdam (2008)

    Google Scholar 

  11. Cunha, A., Pinto, J.S., Proença, J.: A framework for point-free program transformation. In: Butterfield, A., Grelck, C., Huch, F. (eds.) IFL 2005. LNCS, vol. 4015, pp. 1–18. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  12. Cunha, A., Visser, J.: Strongly typed rewriting for coupled software transformation. Electronic Notes in Theoretical Computer Science 174(1), 17–34 (2007)

    Article  Google Scholar 

  13. Cunha, A., Visser, J.: Transformation of structure-shy programs with application to XPath queries and strategic functions. Science of Computer Programming (to appear, 2010)

    Google Scholar 

  14. Diskin, Z.: Algebraic Models for Bidirectional Model Synchronization. In: Czarnecki, K., Ober, I., Bruel, J.-M., Uhl, A., Völter, M. (eds.) MODELS 2008. LNCS, vol. 5301, pp. 21–36. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  15. Foster, J.N., Greenwald, M.B., Moore, J.T., Pierce, B.C., Schmitt, A.: Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Transactions on Programming Languages and Systems 29(3), 17 (2007)

    Article  Google Scholar 

  16. Frisch, A., Castagna, G., Benzaken, V.: Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. Journal of the ACM 55(4), 1–64 (2008)

    Article  MathSciNet  Google Scholar 

  17. Gibbons, J.: Calculating functional programs. In: Blackhouse, R., Crole, R.L., Gibbons, J. (eds.) Algebraic and Coalgebraic Methods in the Mathematics of Program Construction. LNCS, vol. 2297, pp. 149–203. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  18. Hinze, R.: Generic programs and proofs. Bonn University, Habilitation (2000)

    Google Scholar 

  19. Hu, Z., Mu, S.-C., Takeichi, M.: A programmable editor for developing structured documents based on bidirectional transformations. Higher Order and Symbolic Computation 21(1-2), 89–118 (2008)

    Article  MATH  Google Scholar 

  20. Matsuda, K., Hu, Z., Nakano, K., Hamana, M., Takeichi, M.: Bidirectionalization transformation based on automatic derivation of view complement functions. In: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming (ICFP’07), pp. 47–58. ACM, New York (2007)

    Chapter  Google Scholar 

  21. Meertens, L.: Designing constraint maintainers for user interaction (1998), Manuscript available at, http://www.kestrel.edu/home/people/meertens

  22. Meijer, E., Fokkinga, M., Paterson, R.: Functional programming with bananas, lenses, envelopes and barbed wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991)

    Google Scholar 

  23. Morgan, C., Gardiner, P.H.B.: Data refinement by calculation. Acta Informatica 27(6), 481–503 (1990)

    Article  MATH  MathSciNet  Google Scholar 

  24. Mu, S.-C., Hu, Z., Takeichi, M.: An algebraic approach to bi-directional updating. In: Chin, W.-N. (ed.) APLAS 2004. LNCS, vol. 3302, pp. 2–20. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  25. Oliveira, J.N.: Data transformation by calculation. In: Lämmel, R., Visser, J., Saraiva, J. (eds.) Generative and Transformational Techniques in Software Engineering II. LNCS, vol. 5235, pp. 139–198. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  26. Stevens, P.: Bidirectional model transformations in QVT: Semantic issues and open questions. In: Engels, G., Opdyke, B., Schmidt, D.C., Weil, F. (eds.) MODELS 2007. LNCS, vol. 4735, pp. 1–15. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  27. Voigtländer, J.: Bidirectionalization for free! (Pearl). In: Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’09), pp. 165–176. ACM, New York (2009)

    Google Scholar 

  28. Wang, M., Gibbons, J., Matsuda, K., Hu, Z.: Translucent Abstraction: Safe Views through Invertible Programming. Draft (2010), http://web.comlab.ox.ac.uk/files/2280/total.pdf

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Pacheco, H., Cunha, A. (2010). Generic Point-free Lenses. In: Bolduc, C., Desharnais, J., Ktari, B. (eds) Mathematics of Program Construction. MPC 2010. Lecture Notes in Computer Science, vol 6120. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-13321-3_19

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-13321-3_19

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-13320-6

  • Online ISBN: 978-3-642-13321-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics