skip to main content
article

Embedding invertible languages with binders: a case of the FliPpr language

Published:17 September 2018Publication History
Skip Abstract Section

Abstract

This paper describes a new embedding technique of invertible programming languages, through the case of the FliPpr language. Embedded languages have the advantage of inheriting host languages' features and supports; and one of the influential methods of embedding is the tagless-final style, which enables a high level of programmability and extensibility. However, it is not straightforward to apply the method to the family of invertible/reversible/bidirectional languages, due to the different ways functions in such domains are represented. We consider FliPpr, an invertible pretty-printing system, as a representative of such languages, and show that Atkey et al.'s unembedding technique can be used to address the problem. Together with a reformulation of FliPpr, our embedding achieves a high level of interoperability with the host language Haskell, which is not found in any other invertible languages. We implement the idea and demonstrate the benefits of the approach with examples.

References

  1. Robert Atkey. 2009. Syntax for Free: Representing Syntax with Binding Using Parametricity. In TLCA (Lecture Notes in Computer Science), Pierre-Louis Curien (Ed.), Vol. 5608. Springer, 35-49. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Robert Atkey, Sam Lindley, and Jeremy Yallop. 2009. Unembedding domain-specific languages. In Haskell, Stephanie Weirich (Ed.). ACM, 37-48. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Arthur I. Baars, S. Doaitse Swierstra, and Marcos Viera. 2010. Typed Transformations of Typed Grammars: The Left Corner Transform. Electr. Notes Theor. Comput. Sci. 253, 7 (2010), 51-64. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. 2009. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program. 19, 5 (2009), 509-543. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Adam Chlipala. 2008. Parametric higher-order abstract syntax for mechanized semantics. In ICFP, James Hook and Peter Thiemann (Eds.). ACM, 143-156. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Koen Claessen and John Hughes. 2000. QuickCheck: a lightweight tool for random testing of Haskell programs. In ICFP, Martin Odersky and Philip Wadler (Eds.). ACM, 268-279. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Nils Anders Danielsson. 2013. Correct-by-construction pretty-printing. In DTP, Stephanie Weirich (Ed.). ACM, 1-12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jonas Duregård and Patrik Jansson. 2011. Embedded parser generators. In Haskell, Koen Claessen (Ed.). ACM, 107-117. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Sebastian Fischer, Oleg Kiselyov, and Chung-chieh Shan. 2011. Purely functional lazy nondeterministic programming. J. Funct. Program. 21, 4-5 (2011), 413-465. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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. ACM Trans. Program. Lang. Syst. 29, 3 (2007). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Richard A. Frost, Rahmatullah Hafiz, and Paul Callaghan. 2008. Parser Combinators for Ambiguous Left-Recursive Grammars. In PADL (Lecture Notes in Computer Science), Paul Hudak and David Scott Warren (Eds.), Vol. 4902. Springer, 167-181. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Robert Glück and Masahiko Kawabe. 2004. Derivation of Deterministic Inverse Programs Based on LR Parsing. In FLOPS (Lecture Notes in Computer Science), Yukiyoshi Kameyama and Peter J. Stuckey (Eds.), Vol. 2998. Springer, 291-306.Google ScholarGoogle Scholar
  13. Robert Glück and Masahiko Kawabe. 2005. Revisiting an automatic program inverter for Lisp. SIGPLAN Notices 40, 5 (2005), 8-17. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Fritz Henglein. 1993. Type Inference with Polymorphic Recursion. ACM Trans. Program. Lang. Syst. 15, 2 (1993), 253-289. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Qinheping Hu and Loris D'Antoni. 2017. Automatic program inversion using symbolic transducers. In PLDI, Albert Cohen and Martin T. Vechev (Eds.). ACM, 376-389. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. John Hughes. 1995. The Design of a Pretty-printing Library. In Advanced Functional Programming (Lecture Notes in Computer Science), Johan Jeuring and Erik Meijer (Eds.), Vol. 925. Springer, 53-96. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. John Hughes. 2000. Generalising monads to arrows. Sci. Comput. Program. 37, 1-3 (2000), 67-111. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Graham Hutton. 1992. Higher-Order Functions for Parsing. J. Funct. Program. 2, 3 (1992), 323-343.Google ScholarGoogle ScholarCross RefCross Ref
  19. Steven Keuchel and Johan Jeuring. 2012. Generic conversions of abstract syntax representations. In WGP, Andres Löh and Ronald Garcia (Eds.). ACM, 57-68. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Oleg Kiselyov. 2016. Probabilistic Programming Language and its Incremental Evaluation. In APLAS (Lecture Notes in Computer Science), Atsushi Igarashi (Ed.), Vol. 10017. 357-376.Google ScholarGoogle Scholar
  21. Kazutaka Matsuda and Kazuyuki Asada. 2017. A functional reformulation of UnCAL graph-transformations: or, graph transformation as graph reduction. In PEPM, Ulrik Pagh Schultz and Jeremy Yallop (Eds.). ACM, 71-82. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Kazutaka Matsuda, Kazuhiro Inaba, and Keisuke Nakano. 2012. Polynomial-time inverse computation for accumulative functions with multiple data traversals. Higher-Order and Symbolic Computation 25, 1 (2012), 3-38. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Kazutaka Matsuda, Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi. 2010. A Grammar-Based Approach to Invertible Programs. In ESOP (Lecture Notes in Computer Science), Andrew D. Gordon (Ed.), Vol. 6012. Springer, 448-467. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Kazutaka Matsuda and Meng Wang. 2013. FliPpr: A Prettier Invertible Printing System. In ESOP (Lecture Notes in Computer Science), Matthias Felleisen and Philippa Gardner (Eds.), Vol. 7792. Springer, 101-120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Kazutaka Matsuda and Meng Wang. 2015. Applicative bidirectional programming with lenses. In ICFP, Kathleen Fisher and John H. Reppy (Eds.). ACM, 62-74. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Kazutaka Matsuda and Meng Wang. 2018. Applicative bidirectional programming: Mixing lenses and semantic bidirectionalization. J. Funct. Program. 28 (2018), e15.Google ScholarGoogle ScholarCross RefCross Ref
  27. Kazutaka Matsuda and Meng Wang. 2018. HOBiT: Programming Lenses Without Using Lens Combinators. In ESOP (Lecture Notes in Computer Science), Amal Ahmed (Ed.), Vol. 10801. Springer, 31-59.Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Conor McBride and Ross Paterson. 2008. Applicative programming with effects. J. Funct. Program.18, 1 (2008), 1-13. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Naoki Nishida, Masahiko Sakai, and Toshiki Sakabe. 2001. Generation of inverse term rewriting systems for pure treeless functions. In Proceedings of the International Workshop on Rewriting in Proof and Computation. 188-198.Google ScholarGoogle Scholar
  30. Hugo Pacheco and Alcino Cunha. 2010. Generic Point-free Lenses. In MPC (Lecture Notes in Computer Science), Claude Bolduc, Jules Desharnais, and Béchir Ktari (Eds.), Vol. 6120. Springer, 331-352. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Hugo Pacheco, Zhenjiang Hu, and Sebastian Fischer. 2014. Monadic combinators for "Putback" style bidirectional programming. In PEPM, Wei-Ngan Chin and Jurriaan Hage (Eds.). ACM, 39-50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Ross Paterson. 2001. A New Notation for Arrows. In ICFP, Benjamin C. Pierce (Ed.). ACM, 229-240. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Jeff Polakow. 2015. Embedding a full linear Lambda calculus in Haskell. In Haskell, Ben Lippmeier (Ed.). ACM, 177-188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Tillmann Rendel and Klaus Ostermann. 2010. Invertible syntax descriptions: unifying parsing and pretty printing. In Haskell, Jeremy Gibbons (Ed.). ACM, 1-12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Philip Wadler. 1990. Deforestation: Transforming Programs to Eliminate Trees. Theor. Comput. Sci. 73, 2 (1990), 231-248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Philip Wadler. 2003. A Prettier Printer. In The Fun of Programming, Jeremy Gibbons and Oege de Moor (Eds.). Palgrave Macmillan, Chapter 11.Google ScholarGoogle Scholar
  37. Tetsuo Yokoyama. 2010. Reversible Computation and Reversible Programming Languages. Electr. Notes Theor. Comput. Sci. 253, 6 (2010), 71-81. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Tetsuo Yokoyama, Holger Bock Axelsen, and Robert Glück. 2011. Towards a Reversible Functional Language. In RC (Lecture Notes in Computer Science), Alexis De Vos and Robert Wille (Eds.), Vol. 7165. Springer, 14-29. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Embedding invertible languages with binders: a case of the FliPpr language

            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 53, Issue 7
              Haskell '18
              July 2018
              185 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/3299711
              Issue’s Table of Contents
              • cover image ACM Conferences
                Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on Haskell
                September 2018
                185 pages
                ISBN:9781450358354
                DOI:10.1145/3242744

              Copyright © 2018 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 17 September 2018

              Check for updates

              Qualifiers

              • article

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!