Generic Deriving of Generic Traversals
Csongor Kiss, Matthew Pickering, Nicolas Wu

TL;DR
This paper presents a flexible library combining lenses and traversals for querying and modifying complex data structures, leveraging generic data shape to produce efficient code through compiler optimizations.
Contribution
It introduces a novel approach that unifies lenses and traversals using generic data shape analysis to generate efficient, reusable code for complex data manipulation.
Findings
The library enables expressive querying and modification of data structures.
Generated code is as efficient as hand-written implementations.
The approach leverages compiler optimizations like inlining and specialization.
Abstract
Functional programmers have an established tradition of using traversals as a design pattern to work with recursive data structures. The technique is so prolific that a whole host of libraries have been designed to help in the task of automatically providing traversals by analysing the generic structure of data types. More recently, lenses have entered the functional scene and have proved themselves to be a simple and versatile mechanism for working with product types. They make it easy to focus on the salient parts of a data structure in a composable and reusable manner. In this paper, we use the combination of lenses and traversals to give rise to an expressive and flexible library for querying and modifying complex data structures. Furthermore, since our lenses and traversals are based on the generic shape of data, we are able to use this information to produce code that is as…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Model-Driven Software Engineering Techniques · Software Engineering Research
