How to make ad-hoc polymorphism less ad hoc
POPL '89 Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages
Algebra of programming
PolyP—a polytypic programming language extension
Proceedings of the 24th ACM SIGPLAN-SIGACT symposium on Principles of programming languages
Derivatives of Regular Expressions
Journal of the ACM (JACM)
Static prediction of heap space usage for first-order functional programs
POPL '03 Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of programming languages
A functional correspondence between evaluators and abstract machines
Proceedings of the 5th ACM SIGPLAN international conference on Principles and practice of declaritive programming
Faking it Simulating dependent types in Haskell
Journal of Functional Programming
de Bruijn notation as a nested datatype
Journal of Functional Programming
Journal of Functional Programming
Science of Computer Programming - Special issue on mathematics of program construction (MPC 2002)
Containers: constructing strictly positive types
Theoretical Computer Science - Applied semantics: Selected topics
∂ for Data: Differentiating Data Structures
Fundamenta Informaticae - Typed Lambda Calculi and Applications 2003, Selected Papers
SSDGP'06 Proceedings of the 2006 international conference on Datatype-generic programming
Generic programming with fixed points for mutually recursive datatypes
Proceedings of the 14th ACM SIGPLAN international conference on Functional programming
Scrap your zippers: a generic zipper for heterogeneous types
Proceedings of the 6th ACM SIGPLAN workshop on Generic programming
Species and functors and types, oh my!
Proceedings of the third ACM Haskell symposium on Haskell
Proceedings of the 15th ACM SIGPLAN international conference on Functional programming
Generic programming with indexed functors
Proceedings of the seventh ACM SIGPLAN workshop on Generic programming
Generic representations of tree transformations
Proceedings of the 9th ACM SIGPLAN workshop on Generic programming
Hi-index | 0.00 |
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.