I spent some time the other day thinking about zippers and structural editors and I wanted to share some of the ideas, because they were interesting, so this is going to be a thread about that
Post
when we think about editors, the canonical example is a text editor, which is conceptually very simple. in the functional programming context, we often think of editors in terms of a structure called a zipper, which you can read about here:
the usual way of looking at a text editor through the lens of a zipper is to view the string/text as split in two, the stuff before the cursor and the stuff after, with the stuff before the cursor reversed
but the equivalent of this is hard to figure out for tree structures. the closest analog for tree structures has to pluck out an entire subtree, which isn't quite the same thing as splitting a string in two
you can massage the idea of splitting a string by saying well, you've "plucked" out a character from the middle, but i think this is a mistake. we're really dealing with distinct concepts and its useful to try to figure out how to understand their relationship
in particular, I think it's useful to think about the different cursor types that exist in terminals, especially in older settings
what i mean is the difference between vertical line cursors and underline/box cursors