[Haskell-cafe] Re: Updating doubly linked lists

Apfelmus, Heinrich apfelmus at quantentunnel.de
Fri Jan 2 05:50:26 EST 2009

S. Günther wrote:
>> 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.

What kind of structure do you need exactly?

> 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.

Viewing the zipper as the derivative of a data type opens up more

That being said, every algebraic data types has a tree-like structure.
The extra invariants like

   left . right  =  right . left

that the programmer imposes are what make them different from trees.

> So I just have to decide whether to use IORefs/Vars (clunky)
> or to implement zippers for the structure I need (probably too hard for me).

It's not too hard for you. You've got a whole haskell-cafe and #haskell
at your fingertips, after all. ;)

H. Apfelmus

More information about the Haskell-Cafe mailing list