
The folks in the #haskell-lens irc channel helped me out. Installing and
importing http://hackage.haskell.org/package/zippers fixed my problem.
Sounds like it was split out of the lens package at some point.
-Zach
On Sun, Dec 7, 2014 at 11:08 AM, Zach Moazeni
Hello,
I'm trying to understand how I would manipulate a Data.Tree in Haskell. I came across this StackOverflow answer and accompanying blog post, but it doesn't run locally for me:
* http://stackoverflow.com/a/15489761/410759 * https://www.fpcomplete.com/user/davorak/code-snippets/zipper-tree-examples
Here's a gist with the code and the error I'm seeing: https://gist.github.com/zmoazeni/0049f3ab365ae600b131
I just want to start slow and be able to do three actions:
* add +10 to all values in the tree * add a node to an existing node's subForest * remove a node (along with its subForest) from the tree
I understand that this won't actually "edit in place" and my code would need to call a function which would return an updated version of the original tree.
Finally, Lens wasn't my first choice. I was trying to understand Zippers from http://learnyouahaskell.com/zippers and my brain seized. I'm just falling back to Lens because it seems like the simplest/dsl-ish way to manipulate structures like this.
Thanks for any help! -Zach