On Wed, May 15, 2013 at 11:02:44AM +0800, John Lato wrote:
> Thanks for this explanation; I had assumed it was possible and I just would
> need to write that function myself. I think it's just "think hard and bang
> out code" tricky, but it also might lead to diagrams not working as
> expected. Consider this case:
>
> - create a diagram with two named Subdiagrams
> - draw a line between the subdiagrams using the name/connection technique
> - translate one of the subdiagrams
>
> Now the connecting line would go to the old position, leaving the
> subdiagram free.
>
> Generally, any time a user performed some calculation that depended on the
> current envelope/trace/etc., modifying a subdiagram's envelope/trace/etc.
> wouldn't update that calculation.
Yeah, I guess it could end up being surprising either way. But I
think if we want to have things like connections between named points
which track changes to the location of the points, it will have to
wait until we have some sort of system in place for handling diagram
layout via constraint solving. For now the simplest solution (lines
drawn connecting two points don't update if one of the points moves)
is best. In any case I don't think this is a reason not to implement
this feature. You are not the first person to want it --- and usually
what people want it for is to be able to change the attributes of
named subdiagrams (as you do), not move them, in which case it's not
even an issue.
> From an implementation standpoint, the map to each sub-diagram would need
> to be modified every time the tree is modified. This seems like a lot of
> extra book-keeping. Maybe there's a way to change the Submap a bit so it's
> structured like a prefix tree, handling that automatically.
This will be handled automatically when the DUALTree is rebuilt, since
the subdiagram map is an upwards-accumulating monoidal annotation.
I'm not sure what you mean about a prefix tree --- though if there is
a way to simplify/make things more efficient without a whole lot of
extra effort, I'm all for it.
> It should be easy enough to create a zipper over a DUALTree, which would be
> perfect for this sort of manipulation. Would you be interested in having a
> module like that added to DUALTree? Otherwise the same technique could be
> applied implicitly in a special-purpose function in diagrams-core.
Your comment
https://github.com/diagrams/diagrams-core/issues/39#issuecomment-18112401
makes a lot of sense to me. But a zipper over DUALTrees could be very
cool as well (though off the top of my head I'm not confident how it
would work). It sounds like a tricky (but maybe fun) piece of
engineering.
-Brent
----- End forwarded message -----