On Friday, January 27, 2017 at 10:04:50 AM UTC, Rupert Smith wrote: > > The state for this particular piece of the application is held in an > elm-multiway-tree-zipper ( > http://package.elm-lang.org/packages/tomjkidd/elm-multiway-tree-zipper/latest). > > The way to associate a message with part of the tree is to pass a zipper. >
One thing I have come to realize about zipper trees, is that you can only make modificiations to the tree with one zipper at a time. Update operations that make changes to 2 or more parts of the tree in one go are awkward. The reason is that each zipper describes the state - 1 version of the tree. What I want is a zipper that describes state - 1, apply it to get a new temp state, then the second zipper to describe that temp state, then apply it to arrive at the new state for the tree. The exception is when I want to make a change to all parent nodes walking back to the root. So if a deep node is 'opened' for viewing, I probably want to ensure all parent nodes back to the root are also 'opened'. That is possible as when walking the zipper back to the root to form the new tree, the same operation can be applied at all steps. The solution generally seems to be to just walk the whole tree (using map) when changes are to be made to multiple parts of it. I suppose I could make this more efficient by writing a tree walk that only visits parts of the tree that are currently 'opened' as other parts will be hidden from view. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
