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.
- 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 Scholar
Digital Library
- Robert Atkey, Sam Lindley, and Jeremy Yallop. 2009. Unembedding domain-specific languages. In Haskell, Stephanie Weirich (Ed.). ACM, 37-48. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Adam Chlipala. 2008. Parametric higher-order abstract syntax for mechanized semantics. In ICFP, James Hook and Peter Thiemann (Eds.). ACM, 143-156. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Nils Anders Danielsson. 2013. Correct-by-construction pretty-printing. In DTP, Stephanie Weirich (Ed.). ACM, 1-12. Google Scholar
Digital Library
- Jonas Duregård and Patrik Jansson. 2011. Embedded parser generators. In Haskell, Koen Claessen (Ed.). ACM, 107-117. Google Scholar
Digital Library
- Sebastian Fischer, Oleg Kiselyov, and Chung-chieh Shan. 2011. Purely functional lazy nondeterministic programming. J. Funct. Program. 21, 4-5 (2011), 413-465. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Robert Glück and Masahiko Kawabe. 2005. Revisiting an automatic program inverter for Lisp. SIGPLAN Notices 40, 5 (2005), 8-17. Google Scholar
Digital Library
- Fritz Henglein. 1993. Type Inference with Polymorphic Recursion. ACM Trans. Program. Lang. Syst. 15, 2 (1993), 253-289. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- John Hughes. 2000. Generalising monads to arrows. Sci. Comput. Program. 37, 1-3 (2000), 67-111. Google Scholar
Digital Library
- Graham Hutton. 1992. Higher-Order Functions for Parsing. J. Funct. Program. 2, 3 (1992), 323-343.Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Kazutaka Matsuda and Meng Wang. 2015. Applicative bidirectional programming with lenses. In ICFP, Kathleen Fisher and John H. Reppy (Eds.). ACM, 62-74. Google Scholar
Digital Library
- Kazutaka Matsuda and Meng Wang. 2018. Applicative bidirectional programming: Mixing lenses and semantic bidirectionalization. J. Funct. Program. 28 (2018), e15.Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- Conor McBride and Ross Paterson. 2008. Applicative programming with effects. J. Funct. Program.18, 1 (2008), 1-13. Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Ross Paterson. 2001. A New Notation for Arrows. In ICFP, Benjamin C. Pierce (Ed.). ACM, 229-240. Google Scholar
Digital Library
- Jeff Polakow. 2015. Embedding a full linear Lambda calculus in Haskell. In Haskell, Ben Lippmeier (Ed.). ACM, 177-188. Google Scholar
Digital Library
- Tillmann Rendel and Klaus Ostermann. 2010. Invertible syntax descriptions: unifying parsing and pretty printing. In Haskell, Jeremy Gibbons (Ed.). ACM, 1-12. Google Scholar
Digital Library
- Philip Wadler. 1990. Deforestation: Transforming Programs to Eliminate Trees. Theor. Comput. Sci. 73, 2 (1990), 231-248. Google Scholar
Digital Library
- Philip Wadler. 2003. A Prettier Printer. In The Fun of Programming, Jeremy Gibbons and Oege de Moor (Eds.). Palgrave Macmillan, Chapter 11.Google Scholar
- Tetsuo Yokoyama. 2010. Reversible Computation and Reversible Programming Languages. Electr. Notes Theor. Comput. Sci. 253, 6 (2010), 71-81. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Embedding invertible languages with binders: a case of the FliPpr language
Recommendations
Embedding invertible languages with binders: a case of the FliPpr language
Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on HaskellThis 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 ...
FliPpr: A System for Deriving Parsers from Pretty-Printers
AbstractWhen implementing a programming language, we often write a parser and a pretty-printer. However, manually writing both programs is not only tedious but also error-prone; it may happen that a pretty-printed result is not correctly parsed. In this ...
Declarative specification of indentation rules: a tooling perspective on parsing and pretty-printing layout-sensitive languages
SLE 2018: Proceedings of the 11th ACM SIGPLAN International Conference on Software Language EngineeringIn layout-sensitive languages, the indentation of an expression or statement can influence how a program is parsed. While some of these languages (e.g., Haskell and Python) have been widely adopted, there is little support for software language ...







Comments