<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Nice timing, I was just reading Conal Elliott’s take on zippers [1][2] when you sent this question.<div class=""><br class=""></div><div class="">It is interesting because it produces a concrete representation of the zippers via derivatives, like the manually constructed zippers, while still being completely generic*.</div><div class="">I wonder if it is possible to combine the approach with lenses to get the same convenience while still being more concrete and flexible.</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Andreas</div><div class=""><br class=""></div><div class="">[1]: <a href="http://conal.net/blog/posts/another-angle-on-zippers" class="">http://conal.net/blog/posts/another-angle-on-zippers</a></div><div class="">[2]: <a href="http://hackage.haskell.org/package/functor-combo-0.3.6/docs/FunctorCombo-ZipperFix.html" class="">http://hackage.haskell.org/package/functor-combo-0.3.6/docs/FunctorCombo-ZipperFix.html</a></div><div class=""><br class=""></div><div class="">* The library is sadly not implemented in terms of `GHC.Generics`, even though it uses the same combinators, since it predated it.</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">22 Jul 2020 kl. 13:40 skrev Dominik Schrempf <<a href="mailto:dominik.schrempf@gmail.com" class="">dominik.schrempf@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello Cafe!<br class=""><br class="">I am trying to modify a large 'Data.Tree.Tree'. I managed to modify node labels<br class="">with specific indices in the form of @[Int]@ as they are defined in, for<br class="">example, 'Control.Lens.At.Ixed' or 'Lens.Micro.GHC'.<br class=""><br class="">However, I also need to<br class="">1. modify the node label using information from nearby nodes (e.g., the<br class="">   children);<br class="">2. modify the tree structure itself; for example, I may want to change the<br class="">   sub-forest.<br class=""><br class="">Basically, I need a lens that focuses not on the node label, but on the node<br class="">itself. I perceived that this is more difficult.<br class=""><br class="">I tried to use 'Control.Zipper'. I can use zippers to achieve point 1, albeit in<br class="">a complicated way: (1) I need to go downwards to focus the specific node; (2) I<br class="">need to traverse the children to collect data and save the data somewhere (how?<br class="">in let bindings?); (3) I then go back upwards and change the node label using<br class="">the collected data. Even so, I do not really manage to change the actual<br class="">structure of the tree. I also briefly had a look at plates, but do not manage to<br class="">use them in a proper way, maybe because the depth of my structures may be<br class="">several hundred levels.<br class=""><br class="">Did you encounter similar problems in the past or could you point me to<br class="">resources discussing these issues?<br class=""><br class="">Thank you!<br class="">Dominik<br class=""><br class="">_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br class=""></div></body></html>