There and Back Again

Arrows for Invertible Programming

The Generic Haskell source code.

Requires Generic Haskell 1.42, which requires GHC 6.2.2.
It does not work with Hugs, GHCi, or GHC -fgenerics.

The Clean source code.

Requires Clean 2.1, and replace StdGeneric.icl and StdGeneric.dcl in the StdEnv.

Artem Alimarine, Sjaak Smetsers, Arjen van Weelden, Marko van Eekelen, Rinus Plasmeijer.
Invertible programming occurs in the area of data conversion where it is required that the conversion in one direction is the inverse of the other. For that purpose, we introduce bidirectional arrows (bi-arrows). The bi-arrow class is an extension of Haskell's arrow class with an extra combinator that changes the direction of computation. The advantage of the use of bi-arrows for invertible programming is the preservation of invertibility properties using the bi-arrow combinators. Programming with bi-arrows in a polytypic or generic way exploits this the most. Besides bidirectional polytypic examples, including invertible serialization, we give the definition of a monadic bi-arrow transformer, which we use to construct a bidirectional parser/pretty printer.
Full paper, presented at the 2005 ACM SIGPLAN workshop on Haskell, available via the ACM portal.