Hacker News new | ask | show | jobs
by tathougies 3045 days ago
Sure... most people familiar with zippers know that it can be thought of as the algebraic derivative the underlying type.

What’s perhaps less known is that this is the same as ‘differentiating’ the traversal of the data type.

The continuation monad is a sort of ‘derivative’ of a computation in that it nearly captures the ‘infinitesmal’ difference between two steps in a computation.

If your computation is the traversal of your tree, list, or text markup, then you can make a zipper from that without having to declare new data structures. This is isomorphic to declaring your own data structure. Its only advantage is convenience (that I know of at least).

Oleg Kiselyov goes into great detail with this idea and has lots of example code: http://okmij.org/ftp/continuations/zipper.html

1 comments

Thanks for the answer, it'll keep me busy for a week or two!