[Haskell-cafe] Re: Updating doubly linked lists
h8spawn at googlemail.com
Thu Jan 1 18:48:50 EST 2009
> Whether circular or not, sharing values by using a "back pointer" is
> problematic for any update. Why not use a zipper instead?
I looked into zippers before and the problem I had was that they never
really matched the structure which I needed and which led me to think
about this whole knot tying thing again. The things I read about them
always assumed either a list like (i.e. linear) or a tree like (i.e. existence
of a root) structure on the type to be plugged into the zipper. Now I know
that this is not necessary and there are references to a generic zipper
implementation but the thing is that I only found the source code and
decided to first look into the knot tying thing before opening another
can of worms with delimited continuations since I already spend too
muchtime thinking about that stuff. So if anyone has pointers to a
good generic zipper explanation I would be thankful. Note that I don't
need full blown error handling. I would first like to understand the basics.
Now I think I came to the conclusion that locally updating a tied knot in a
pure way really is hard and that it's not me just not seeing some obvious
solution. So I just have to decide whether to use IORefs/Vars (clunky)
or to implement zippers for the structure I need (probably toohard for me).
Anyways thanks for all the answers from which I learned a few unexpected
things and which assured me that my instincts aren't that far off.
Cheers and warm regards (and a happy new year)
: "Again" means that I already looked into both tying the knot and
zippers about a year ago out of curiosity. This time it was out of necessity
although the original question I posed was more a necessity diverging
into curiosity again.
: Note that "too much time" rather refers to the quantity I have at my
disposal than to personal preferences. If I could I would like nothing more
than to think about this "stuff" for the rest of my life.
More information about the Haskell-Cafe