[darcs-users] neat paper

David Roundy droundy at abridgegame.org
Mon Mar 29 11:17:31 UTC 2004

On Sun, Mar 28, 2004 at 03:16:49PM -0800, Adam Megacz wrote:
> David Roundy <droundy at abridgegame.org> writes:
> > paper, so I'm not sure how well this would work.  The question (or one
> > interesting question, anyways) would be whether an arbitrary parser can
> > be mapped to a lens.  I.e. if a parser could be written as a lens
> > mapping from a flat tree to a structured tree.
> Yeah, kinda like taking darcs' advanced diff format (token replacement,
> etc) to the limit -- as long as you can provide a lens for a given file
> format, darcs would be able to do much more intelligent diff/patch/merge
> operations on the tree structure instead of a big pile of text lines.
> Imagine parse-tree level source code diffing... ;)

That's what I'm imagining! :) The hard part is figuring out how to do the
commutes.  Either all the patches have to be done in the same lens in order
to commute, in which case commuting is relatively easy, but you have
problems, for example, with changes that don't parse properly.  Or you have
to be able to figure out which patches in which lenses commute with patches
in other lenses, which is the ideal way to do it.  I've been thinking about
how the existing darcs patches could be thought of in terms of lenses, and
I think that's a promising avenue.

The hard part will likely be dealing with the vast flexibility that may
come with introducing lensing and a lensing language.  I'm hoping that
there can actually be (almost?) a reduction of primitives.  Once we support
hierarchical structures *within* a file, the same primitives that
manipulate those structures within files might be used to manipulate the
hierarchical directory structure, which would be *very* nice, as it would
make it possible to the write the commute and merge functions just once for
both sorts of operations.  On the other hand, this is clearly very post-1.0
land, so I should probably be getting back to darcs as it is...

BTW, I've been in touch with some of the lensing folks, who have been
friendly.  They aren't sure their work is the most relevant to darcs, but
have pointed me at some other groups (which I haven't gotten around to
checking out).
David Roundy

More information about the darcs-users mailing list