ACM Home Page
Please provide us with feedback. Feedback
Clowns to the left of me, jokers to the right (pearl): dissecting data structures
Full text PdfPdf (204 KB)
Source
Annual Symposium on Principles of Programming Languages archive
Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages table of contents
San Francisco, California, USA
SESSION: Session 9 table of contents
Pages 287-295  
Year of Publication: 2008
ISBN:978-1-59593-689-9
Also published in ...
Author
Conor McBride  University of Nottingham, Nottingham, United Kingdom
Sponsors
ACM: Association for Computing Machinery
SIGACT: ACM Special Interest Group on Algorithms and Computation Theory
SIGPLAN: ACM Special Interest Group on Programming Languages
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 12,   Downloads (12 Months): 107,   Citation Count: 0
Additional Information:

abstract   references   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/1328438.1328474
What is a DOI?

ABSTRACT

This paper introduces a small but useful generalisation to the 'derivative' operation on datatypes underlying Huet's notion of 'zipper', giving a concrete representation to one-hole contexts in data which is undergoing transformation. This operator, 'dissection', turns a container-like functor into a bifunctor representing a one-hole context in which elements to the left of the hole are distinguished in type from elements to its right.

I present dissection here as a generic program, albeit for polynomial functors only. The notion is certainly applicable more widely, but here I prefer to concentrate on its diverse applications. For a start, map-like operations over the functor and fold-like operations over the recursive data structure it induces can be expressed by tail recursion alone. Further, the derivative is readily recovered from the dissection. Indeed, it is the dissection structure which delivers Huet's operations for navigating zippers.

The original motivation for dissection was to define 'division', capturing the notion of leftmost hole, canonically distinguishing values with no elements from those with at least one. Division gives rise to an isomorphism corresponding to the remainder theorem in algebra. By way of a larger example, division and dissection are exploited to give a relatively efficient generic algorithm for abstracting all occurrences of one term from another in a first-order syntax. The source code for the paper is available online and compiles with recent extensions to the Glasgow Haskell Compiler.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

 
1
 
2
3
 
4
William Aitken and John Reppy. Abstract value constructors. Technical Report TR 92-1290, Cornell University, 1992.
 
5
Michael Barr and Charles Wells. Toposes, Triples and Theories, chapter 9. Number 278 in Grundlehren der Mathematischen Wissenschaften. Springer, New York, 1984.
 
6
 
7
8
 
9
Jean-Christophe Filliatre. Backtracking iterators. Technical Report 1428, CNRS-LRI, January 2006.
 
10
Jeremy Gibbons. Datatype-generic programming. In Roland Backhouse, Jeremy Gibbons, Ralf Hinze, and Johan Jeuring, editors, Spring School on Datatype-Generic Programming, volume 4719 of Lecture Notes in Computer Science. Springer-Verlag, 2007. To appear.
 
11
Thomas Hallgren. Fun with functional dependencies. In Joint Winter Meeting of the Departments of Science and Computer Engineering, Chalmers University of Technology and Goteborg University, Varberg, Sweden., January 2001.
 
12
13
 
14
15
 
16
Andre Joyal. Foncteurs analytiques et especes de structures. In Combinatoire enumerative, number 1234 in LNM, pages 126--159. 1986.
 
17
Conor McBride. The Derivative of a Regular Type is its Type of One-Hole Contexts. Available at http://www.cs.nott.ac.uk/~ctm/diff.pdf, 2001.
 
18
 
19
Matthias Neubauer, Peter Thiemann, Martin Gasbichler, and Michael Sperber. A Functional Notation for Functional Dependencies. In The 2001 ACM SIGPLAN Haskell Workshop, Firenze, Italy, September 2001.
 
20
Simon Peyton Jones, Mark Jones, and Erik Meijer. Type classes: an exploration of the design space. In Proceedings of the Haskell Workshop, Amsterdam, The Netherlands, June 1997.
21