Notions of Bidirectional Computation and Entangled State Monads

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

Abstract

Bidirectional transformations (bx) support principled consistency maintenance between data sources. Each data source corresponds to one perspective on a composite system, manifested by operations to ‘get’ and ‘set’ a view of the whole from that particular perspective. Bx are important in a wide range of settings, including databases, interactive applications, and model-driven development. We show that bx are naturally modelled in terms of mutable state; in particular, the ‘set’ operations are stateful functions. This leads naturally to considering bx that exploit other computational effects too, such as I/O, nondeterminism, and failure, all largely ignored in the bx literature to date. We present a semantic foundation for symmetric bidirectional transformations with effects. We build on the mature theory of monadic encapsulation of effects in functional programming, develop the equational theory and important combinators for effectful bx, and provide a prototype implementation in Haskell along with several illustrative examples.

Notes

Acknowledgements

Preliminary work on this topic was presented orally at the BIRS workshop 13w5115 in December 2013; a four-page abstract [4] of some of the ideas in this paper appeared at the Athens BX Workshop in March 2014; and a short presentation on an alternative coalgebraic approach [2] was made at CMCS 2014. We thank the organisers of and participants at those meetings and the anonymous reviewers for their helpful comments. The work was supported by the UK EPSRC-funded project A Theory of Least Change for Bidirectional Transformations [34] (EP/K020218/1, EP/K020919/1).

References

  1. 1.
    Abou-Saleh, F., Cheney, J., Gibbons, J., McKinna, J., Stevens, P.: Notions of bidirectional computation and entangled state monads. Technical report, TLCBX project (2015), extended version with proofs, available from http://arxiv.org/abs/1505.02579
  2. 2.
    Abou-Saleh, F., McKinna, J.: A coalgebraic approach to bidirectional transformations (2014). Short presentation at CMCSGoogle Scholar
  3. 3.
    Brady, E.: Programming and reasoning with algebraic effects and dependent types. In: ICFP, pp. 133–144. ACM (2013)Google Scholar
  4. 4.
    Cheney, J., McKinna, J., Stevens, P., Gibbons, J., Abou-Saleh, F.: Entangled state monads (abstract). In: Terwilliger and Hidaka [33]Google Scholar
  5. 5.
    Cicchetti, A., Di Ruscio, D., Eramo, R., Pierantonio, A.: JTL: a bidirectional and change propagating transformation language. In: Malloy, B., Staab, S., van den Brand, M. (eds.) SLE 2010. LNCS, vol. 6563, pp. 183–202. Springer, Heidelberg (2011) CrossRefGoogle Scholar
  6. 6.
    Czarnecki, K., Foster, J.N., Hu, Z., Lämmel, R., Schürr, A., Terwilliger, J.F.: Bidirectional transformations: a cross-discipline perspective. In: Paige, R.F. (ed.) ICMT 2009. LNCS, vol. 5563, pp. 260–283. Springer, Heidelberg (2009) CrossRefGoogle Scholar
  7. 7.
    Diskin, Z., Xiong, Y., Czarnecki, K.: From state- to delta-based bidirectional model transformations: the asymmetric case. JOT 10(6), 1–25 (2011)Google Scholar
  8. 8.
    Diviánszky, P.: LGtk API correction, April 2013. http://people.inf.elte.hu/divip/LGtk/CorrectedAPI.html
  9. 9.
    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. In: POPL, pp. 233–246. ACM (2005)Google Scholar
  10. 10.
    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 TOPLAS 29(3), 17 (2007). Extended version of [9]CrossRefGoogle Scholar
  11. 11.
    Gibbons, J., Hinze, R.: Just do it: Simple monadic equational reasoning. In: ICFP, pp. 2–14. ACM (2011)Google Scholar
  12. 12.
    Hegner, S.J.: An order-based theory of updates for closed database views. Ann. Math. Art. Int. 40, 63–125 (2004)MATHMathSciNetCrossRefGoogle Scholar
  13. 13.
    Hofmann, M., Pierce, B.C., Wagner, D.: Symmetric lenses. In: POPL, pp. 371–384. ACM (2011)Google Scholar
  14. 14.
    Hofmann, M., Pierce, B.C., Wagner, D.: Edit lenses. In: POPL, pp. 495–508. ACM (2012)Google Scholar
  15. 15.
    Hyland, M., Plotkin, G.D., Power, J.: Combining effects: Sum and tensor. TCS 357(1–3), 70–99 (2006)MATHMathSciNetCrossRefGoogle Scholar
  16. 16.
    Johnson, M., Rosebrugh, R.: Spans of lenses. In: Terwilliger and Hidaka [33]Google Scholar
  17. 17.
    Jones, M.P., Duponcheel, L.: Composing monads. Technical report RR-1004, DCS, Yale (1993)Google Scholar
  18. 18.
    Kagawa, K.: Compositional references for stateful functional programming. In: ICFP, pp. 217–226 (1997)Google Scholar
  19. 19.
    Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: ICFP, pp. 145–158. ACM (2013)Google Scholar
  20. 20.
    Kmett, E.: lens-4.0.4 library. http://hackage.haskell.org/package/lens
  21. 21.
    Liang, S., Hudak, P., Jones, M.P.: Monad transformers and modular interpreters. In: POPL, pp. 333–343 (1995)Google Scholar
  22. 22.
    Lüth, C., Ghani, N.: Composing monads using coproducts. In: ICFP, pp. 133–144. ACM (2002)Google Scholar
  23. 23.
    Macedo, N., Cunha, A., Pacheco, H.: Toward a framework for multidirectional model transformations. In: Terwilliger and Hidaka [33]Google Scholar
  24. 24.
    Moggi, E.: Notions of computation and monads. Inf. Comp. 93(1), 55–92 (1991)MATHMathSciNetCrossRefGoogle Scholar
  25. 25.
    Mossakowski, T., Schröder, L., Goncharov, S.: A generic complete dynamic logic for reasoning about purity and effects. FAC 22(3–4), 363–384 (2010)MATHGoogle Scholar
  26. 26.
    OMG: MOF 2.0 Query/View/Transformation specification (QVT), version 1.1, January 2011. http://www.omg.org/spec/QVT/1.1/
  27. 27.
    Pacheco, H., Hu, Z., Fischer, S.: Monadic combinators for “putback” style bidirectional programming. In: PEPM, pp. 39–50. ACM (2014). http://doi.acm.org/10.1145/2543728.2543737
  28. 28.
    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
  29. 29.
    Plotkin, G.D., Pretnar, M.: Handling algebraic effects. LMCS 9(4), 1–36 (2013)MathSciNetGoogle Scholar
  30. 30.
    Shkaravska, O.: Side-effect monad, its equational theory and applications (2005), seminar slides available at: http://www.ioc.ee/~tarmo/tsem05/shkaravska1512-slides.pdf
  31. 31.
    Stevens, P.: Bidirectional model transformations in QVT: Semantic issues and open questions. SoSyM 9(1), 7–20 (2010)Google Scholar
  32. 32.
    Stevens, P., McKinna, J., Cheney, J.: ‘Composers’ example (2014). http://bx-community.wikidot.com/examples:composers
  33. 33.
    Terwilliger, J., Hidaka, S. (eds.): BX Workshop (2014). http://ceur-ws.org/Vol-1133/#bx
  34. 34.
    TLCBX Project: A theory of least change for bidirectional transformations (2013–2016). http://www.cs.ox.ac.uk/projects/tlcbx/, http://groups.inf.ed.ac.uk/bx/
  35. 35.
    Varró, D.: Model transformation by example. In: Wang, J., Whittle, J., Harel, D., Reggio, G. (eds.) MoDELS 2006. LNCS, vol. 4199, pp. 410–424. Springer, Heidelberg (2006) CrossRefGoogle Scholar
  36. 36.
    Voigtländer, J., Hu, Z., Matsuda, K., Wang, M.: Enhancing semantic bidirectionalization via shape bidirectionalizer plug-ins. JFP 23(5), 515–551 (2013)MATHGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  • Faris Abou-Saleh
    • 1
  • James Cheney
    • 2
  • Jeremy Gibbons
    • 1
  • James McKinna
    • 2
  • Perdita Stevens
    • 2
  1. 1.Department of Computer ScienceUniversity of OxfordOxfordUK
  2. 2.School of InformaticsUniversity of EdinburghEdinburghUK

Personalised recommendations