Reflections on Monadic Lenses

  • Faris Abou-Saleh
  • James Cheney
  • Jeremy Gibbons
  • James McKinna
  • Perdita Stevens
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9600)


Bidirectional transformations (bx) have primarily been modeled as pure functions, and do not account for the possibility of the side-effects that are available in most programming languages. Recently several formulations of bx that use monads to account for effects have been proposed, both among practitioners and in academic research. The combination of bx with effects turns out to be surprisingly subtle, leading to problems with some of these proposals and increasing the complexity of others. This paper reviews the proposals for monadic lenses to date, and offers some improved definitions, paying particular attention to the obstacles to naively adding monadic effects to existing definitions of pure bx such as lenses and symmetric lenses, and the subtleties of equivalence of symmetric bidirectional transformations in the presence of effects.



The work was supported by the UK EPSRC-funded project A Theory of Least Change for Bidirectional Transformations (TLCBX Project 2013–2016) (EP/K020218/1, EP/K020919/1).

Supplementary material


  1. Abou-Saleh, F., Cheney, J., Gibbons, J., McKinna, J., Stevens, P.: Notions of bidirectional computation and entangled state monads. In: Hinze, R., Voigtländer, J. (eds.) MPC 2015. LNCS, vol. 9129, pp. 187–214. Springer, Heidelberg (2015a)Google Scholar
  2. Abou-Saleh, F., McKinna, J., Gibbons, J.: Coalgebraic aspects of bidirectional computation. In: BX 2015, CEUR-WS, vol. 1396, pp. 15–30 (2015b)Google Scholar
  3. Cheney, J., McKinna, J., Stevens, P., Gibbons, J., Abou-Saleh, F.: Entangled state monads. In: Terwilliger and Hidaka (2014)Google Scholar
  4. Diviánszky, P.: LGtk API correction.
  5. 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. TOPLAS 29(3), 17 (2007)CrossRefGoogle Scholar
  6. Foster, N., Matsuda, K., Voigtländer, J.: Three complementary approaches to bidirectional programming. In: Gibbons, J. (ed.) Generic and Indexed Programming. LNCS, vol. 7470, pp. 1–46. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  7. Hofmann, M., Pierce, B.C., Wagner, D.: Symmetric lenses. In: POPL, pp. 371–384. ACM (2011)Google Scholar
  8. Johnson, M., Rosebrugh, R.: Spans of lenses. In: Terwilliger and Hidaka (2014)Google Scholar
  9. Jones, M.P., Duponcheel, L.: Composing monads. Technical report RR-1004, DCS, Yale (1993)Google Scholar
  10. King, D.J., Wadler, P.: Combining monads. In: Proceedings of the 1992 Glasgow Workshop on Functional Programming, pp. 134–143 (1992)Google Scholar
  11. Liang, S., Hudak, P., Jones, M.P.: Monad transformers and modular interpreters. In: POPL, pp. 333–343 (1995)Google Scholar
  12. Pacheco, H., Hu, Z., Fischer, S.: Monadic combinators for “putback” style bidirectional programming. In: PEPM, pp. 39–50. ACM (2014).
  13. Plotkin, G., Power, J.: Notions of computation determine monads. In: Nielsen, M., Engberg, U. (eds.) FOSSACS 2002. LNCS, vol. 2303, pp. 342–356. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  14. Stevens, P.: Bidirectional model transformations in QVT: Semantic issues and open questions. SoSyM 9(1), 7–20 (2010)Google Scholar
  15. Terwilliger, J., Hidaka, S. (eds.): BX Workshop (2014).
  16. TLCBX Project: a theory of least change for bidirectional transformations (2013–2016).,
  17. Wadler, P.: Comprehending monads. Math. Struct. Comput. Sci. 2(4), 461–493 (1992). MathSciNetCrossRefzbMATHGoogle Scholar
  18. Wadler, P.: Monads for functional programming. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 24–52. Springer, Heidelberg (1995)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  • Faris Abou-Saleh
    • 1
  • James Cheney
    • 2
  • Jeremy Gibbons
    • 1
  • James McKinna
    • 2
  • Perdita Stevens
    • 2
  1. 1.University of OxfordOxfordUK
  2. 2.University of EdinburghEdinburghUK

Personalised recommendations