Research indexBook chapter
Composing Bidirectional Programs Monadically
Xia, Orchard, Wang
Lecture notes in computer science1 Jan 2019Open access
NobleIDark:/48914/w1/20260525/46E42749DOI10.1007/978-3-030-17184-1_6
Composing Bidirectional Programs Monadically
Xia, Orchard, Wang · Lecture notes in computer science · 2019
NobleIDark:/48914/w1/20260525/46E42749DOI10.1007/978-3-030-17184-1_6
Abstract
Software frequently converts data from one representation to another and vice versa. Naïvely specifying both conversion directions separately is error prone and introduces conceptual duplication. Instead, bidirectional programming techniques allow programs to be written which can be interpreted in both directions. However, these techniques often employ unfamiliar programming idioms via restricted, specialised combinator libraries. Instead, we introduce a framework for composing bidirectional programs monadically, enabling bidirectional programming with familiar abstractions in functional languages such as Haskell. We demonstrate the generality of our approach applied to parsers/printers, lenses, and generators/predicates. We show how to leverage compositionality and equational reasoning for the verification of round-tripping properties for such monadic bidirectional programs.