[Haskell-cafe] Re: Zippers

Cristiano Paris frodo at theshire.org
Wed Mar 4 15:53:44 EST 2009

On Wed, Mar 4, 2009 at 12:50 PM, Heinrich Apfelmus
<apfelmus at quantentunnel.de> wrote:
> ...
> The unusual thing about your implementation is probably that you're
> tying a knot by making both  moveUp  and  moveLeft  record fields. This
> reminds me of
>  Weaving a web. Ralf Hinze and Johan Jeuring. 2001.
>  http://www.informatik.uni-bonn.de/~ralf/publications/TheWeb.ps.gz
> The problem with knot-tying / sharing is of course that they are tricky
> to update. What about the crucial function
>  update :: ZContext a -> Maybe a -> ZContext a
> that changes the data at a leaf? I think that with your current
> approach, you'd have to regenerate the whole context which pretty much
> defeats the purpose of a zipper.

Hi Heinrich and thanks for your reply. I haven't read the paper (which
I'm going to read now) but I don't fully understand your point.

I'd (and indeed I did) write 'update' as:

update z x = z { this = this z >> Just x }

exploiting the '>>' operator's logic. How would this differ from the
corresponding 'update' in the original Huet's FP? Maybe I don't get
how my update would impact performances. In both cases the update
functions leave context unchanged, don't they? If my update function
have to replicate the context since functional values are immutable,
doesn't Huet's do the same?

Thank you for any further comments.


More information about the Haskell-Cafe mailing list