Generic deriving of generic traversals
File(s)3236780.pdf (775.47 KB)
Published version
Author(s)
Kiss, Csongor
Pickering, Matthew
Wu, Nicolas
Type
Journal Article
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.
This paper uses the combination of lenses and traversals to give rise to a library with unprecedented expressivity and flexibility for querying and modifying complex data structures. Furthermore, since lenses and traversals are based on the generic shape of data, this information is used to generate code that is as efficient as hand-optimised versions. The technique leverages the structure of data to produce generic abstractions that are then eliminated by the standard workhorses of modern functional compilers: inlining and specialisation.
This paper uses the combination of lenses and traversals to give rise to a library with unprecedented expressivity and flexibility for querying and modifying complex data structures. Furthermore, since lenses and traversals are based on the generic shape of data, this information is used to generate code that is as efficient as hand-optimised versions. The technique leverages the structure of data to produce generic abstractions that are then eliminated by the standard workhorses of modern functional compilers: inlining and specialisation.
Date Issued
2018-09-01
Date Acceptance
2018-05-16
Citation
Proceedings of the ACM on Programming Languages, 2018, 2, pp.1-32
ISSN
2475-1421
Publisher
Association for Computing Machinery (ACM)
Start Page
1
End Page
32
Journal / Book Title
Proceedings of the ACM on Programming Languages
Volume
2
Copyright Statement
© 2018 Copyright held by the owner/author(s). This work is licensed under a Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/)
Identifier
http://gateway.webofknowledge.com/gateway/Gateway.cgi?GWVersion=2&SrcApp=PARTNER_APP&SrcAuth=LinksAMR&KeyUT=WOS:000461309200019&DestLinkType=FullRecord&DestApp=ALL_WOS&UsrCustomerID=1ba7043ffcc86c417c072aa74d649202
Subjects
Science & Technology
Technology
Computer Science, Software Engineering
Computer Science
generic programming
traversals
lenses
extensibility
Publication Status
Published
Coverage Spatial
St Louis, MO
OA Location
https://dl.acm.org/doi/10.1145/3236780
Article Number
ARTN 85
Date Publish Online
2018-07-30