# What is a zipper, and how does it relate to a tree-like structure?

I was reading a chapter in LYAH which didn't really make sense to me. I understand that zippers can arbitrarily traverse a tree-like structure, but I need some clarification on it. Also, can zippers be generalized to any data structure?

• This is probably more appropriate for Computer Science, though the work generalising zippers involves quite some technical machinery. – Dave Clarke Dec 8 '12 at 20:59
• A zipper is something that you should always keep closed, especially when traversing a tree. – Andrej Bauer Dec 8 '12 at 22:44

The path is how you actually apply changes to the structure: "go down, go left, increment the value". By repeatedly applying "go up" (go_up in Huet's paper) at this point, you can retrace your steps and end up with a new, mutated, copy of the original structure.