skip to main content
research-article
Open access

Fusing Direct Manipulations into Functional Programs

Published: 05 January 2024 Publication History

Abstract

Bidirectional live programming systems (BLP) enable developers to modify a program by directly manipulating the program output, so that the updated program can produce the manipulated output. One state-of-the-art approach to BLP systems is operation-based, which captures the developer's intention of program modifications by taking how the developer manipulates the output into account. The program modifications are usually hard coded for each direct manipulation in these BLP systems, which are difficult to extend. Moreover, to reflect the manipulations to the source program, these BLP systems trace the modified output to appropriate code fragments and perform corresponding code transformations. Accordingly, they require direct manipulation users be aware of the source code and how it is changed, making "direct" manipulation (on output) be "indirect".
In this paper, we resolve this problem by presenting a novel operation-based framework for bidirectional live programming, which can automatically fuse direct manipulations into the source code, thus supporting code-insensitive direct manipulations. Firstly, we design a simple but expressive delta language DM capable of expressing common direct manipulations for output values. Secondly, we present a fusion algorithm that propagates direct manipulations into the source functional programs and applies them to the constants whenever possible; otherwise, the algorithm embeds manipulations into the "proper positions" of programs. We prove the correctness of the fusion algorithm that the updated program executes to get the manipulated output. To demonstrate the expressiveness of DM and the effectiveness of our fusion algorithm, we have implemented FuseDM, a prototype SVG editor that supports GUI-based operations for direct manipulation, and successfully designed 14 benchmark examples starting from blank code using FuseDM.

References

[1]
F. Bancilhon and N. Spyratos. 1981. Update Semantics of Relational Views. ACM Trans. Database Syst., 6, 4 (1981), dec, 557–575. issn:0362-5915 https://doi.org/10.1145/319628.319634
[2]
Wei-Ngan Chin. 1992. Safe Fusion of Functional Expressions. SIGPLAN Lisp Pointers, V, 1 (1992), jan, 11–20. issn:1045-3563 https://doi.org/10.1145/141478.141494
[3]
Ravi Chugh, Brian Hempel, Mitchell Spradlin, and Jacob Albers. 2016. Programmatic and direct manipulation, together at last. Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation, Jun, https://doi.org/10.1145/2908080.2908103
[4]
Evan Czaplicki. 2012. Elm: A delightful language for reliable webapps. https://elm-lang.org/ Accessed: 2023-07-04
[5]
Krzysztof Czarnecki, Nate Foster, Zhenjiang Hu, Ralf Lämmel, Andy Schürr, and James Terwilliger. 2009. Bidirectional Transformations: A Cross-Discipline Perspective. 5563, 260–283. isbn:978-3-642-02407-8 https://doi.org/10.1007/978-3-642-02408-5_19
[6]
Zinovy Diskin, Yingfei Xiong, and Krzysztof Czarnecki. 2010. From State- to Delta-Based Bidirectional Model Transformations. In Proceedings of the Third International Conference on Theory and Practice of Model Transformations (ICMT’10). Springer-Verlag, Berlin, Heidelberg. 61–76. isbn:3642136877
[7]
Zinovy Diskin, Yingfei Xiong, Krzysztof Czarnecki, Hartmut Ehrig, Frank Hermann, and Fernando Orejas. 2011. From State- to Delta-Based Bidirectional Model Transformations: The Symmetric Case. In Proceedings of the 14th International Conference on Model Driven Engineering Languages and Systems (MODELS’11). Springer-Verlag, Berlin, Heidelberg. 304–318. isbn:9783642244841
[8]
J. Nathan Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. 2007. Combinators for Bidirectional Tree Transformations: A Linguistic Approach to the View-Update Problem. 29, 3 (2007), may, 17–es. issn:0164-0925 https://doi.org/10.1145/1232420.1232424
[9]
Koumei Fukahori, Daisuke Sakamoto, Jun Kato, and Takeo Igarashi. 2014. CapStudio: An Interactive Screencast for Visual Application Development. Conference on Human Factors in Computing Systems - Proceedings, isbn:978-1-4503-2474-8 https://doi.org/10.1145/2559206.2581138
[10]
Brian Hempel and Ravi Chugh. 2016. Semi-Automated SVG Programming via Direct Manipulation. In Proceedings of the 29th Annual Symposium on User Interface Software and Technology (UIST ’16). Association for Computing Machinery, New York, NY, USA. 379–390. isbn:9781450341899 https://doi.org/10.1145/2984511.2984575
[11]
Brian Hempel, Justin Lubin, and Ravi Chugh. 2019. Sketch-n-Sketch: Output-Directed Programming for SVG. In Proceedings of the 32nd Annual ACM Symposium on User Interface Software and Technology (UIST ’19). Association for Computing Machinery, New York, NY, USA. 281–292. isbn:9781450368162 https://doi.org/10.1145/3332165.3347925
[12]
Martin Hofmann, Benjamin Pierce, and Daniel Wagner. 2012. Edit Lenses. In Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’12). Association for Computing Machinery, New York, NY, USA. 495–508. isbn:9781450310833 https://doi.org/10.1145/2103656.2103715
[13]
Mikaël Mayer, Viktor Kuncak, and Ravi Chugh. 2018. Bidirectional Evaluation with Direct Manipulation. Proc. ACM Program. Lang., 2, OOPSLA (2018), Article 127, oct, 28 pages. https://doi.org/10.1145/3276497
[14]
Sergey Melnik, Atul Adya, and Philip A. Bernstein. 2008. Compiling Mappings to Bridge Applications and Databases. ACM Trans. Database Syst., 33, 4 (2008), Article 22, dec, 50 pages. issn:0362-5915 https://doi.org/10.1145/1412331.1412334
[15]
Atsushi Ohori and Isao Sasano. 2007. Lightweight Fusion by Fixed Point Promotion. In Proceedings of the 34th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’07). Association for Computing Machinery, New York, NY, USA. 143–154. isbn:1595935754 https://doi.org/10.1145/1190216.1190241
[16]
Armando Solar-Lezama. 2008. Program synthesis by sketching. University of California, Berkeley.
[17]
Akihiko Takano and Erik Meijer. 1995. Shortcut Deforestation in Calculational Form. In Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture (FPCA ’95). Association for Computing Machinery, New York, NY, USA. 306–313. isbn:0897917197 https://doi.org/10.1145/224164.224221
[18]
Vlad Ureche, Aggelos Biboudis, Yannis Smaragdakis, and Martin Odersky. 2015. Automating Ad Hoc Data Representation Transformations. SIGPLAN Not., 50, 10 (2015), oct, 801–820. issn:0362-1340 https://doi.org/10.1145/2858965.2814271
[19]
H. von Koch. 1904. Sur une courbe continue sans tangente obtenue par une construction geometrique elementaire. Norstedt & soner. https://books.google.com.hk/books?id=kf3NnQAACAAJ
[20]
Philip Wadler. 1988. Deforestation: Transforming Programs to Eliminate Trees. Theor. Comput. Sci., 73, 2 (1988), jan, 231–248. issn:0304-3975 https://doi.org/10.1016/0304-3975(90)90147-A
[21]
Xing Zhang, Guanchen Guo, Xiao He, and Zhenjiang Hu. 2023. Bidirectional Object-Oriented Programming: Towards Programmatic and Direct Manipulation of Objects. Proc. ACM Program. Lang., 7, OOPSLA1 (2023), Article 83, apr, 26 pages. https://doi.org/10.1145/3586035
[22]
Xing Zhang and Zhenjiang Hu. 2022. Towards Bidirectional Live Programming for Incomplete Programs. In Proceedings of the 44th International Conference on Software Engineering (ICSE ’22). Association for Computing Machinery, New York, NY, USA. 2154–2164. isbn:9781450392211 https://doi.org/10.1145/3510003.3510195
[23]
Xing Zhang, Ruifeng Xie, Guanchen Guo, Xiao He, Tao Zan, and Zhenjiang Hu. 2023. FuseDM. https://doi.org/10.5281/zenodo.8419913

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 8, Issue POPL
January 2024
2820 pages
EISSN:2475-1421
DOI:10.1145/3554315
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 05 January 2024
Published in PACMPL Volume 8, Issue POPL

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. Bidirectional Programming
  2. Direct Manipulation
  3. FuseDM

Qualifiers

  • Research-article

Funding Sources

  • the National Key Research and Development Program of China
  • the Natural Science Foundation of Fujian Province for Youths

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 322
    Total Downloads
  • Downloads (Last 12 months)322
  • Downloads (Last 6 weeks)55
Reflects downloads up to 09 Nov 2024

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media