Yeah, currently there is no functionality to let you modify a
subdiagram, although I have certainly considered it before. It's
tricky. Off the top of my head I do not know/remember whether it is
"major redesign"- tricky or just "someone needs to sit down and think
hard for a bit and bang out the code"-tricky. The problem is that
name maps are represented as just a finite map from names to
subdiagrams---in particular the information about where a subdiagram
sits within the tree corresponding to its parent diagram is not
stored, so there is no way to rebuild a parent diagram with a modified
subdiagram. Hmm, I suppose that along with each subdiagram we could store the
path from the root to the subdiagram. That might make a nice project
for someone.
OK, I created
https://github.com/diagrams/diagrams-core/issues/39 for this.
In the meantime, one potential (though not all that nice) workaround
is to work with things of type
Map String Diagram
instead of directly with Diagrams. This means you essentially have to
manage the names yourself. However, because of various instances for
Maps (HasOrigin, Juxtaposable, Enveloped, ...) these should behave in
many ways just like the diagram you get when you mconcat all the
diagram values stored in the map. Obviously it is easy to modify
individual values stored in the map, and you can apply (mconcat
. elems) at the very end.
http://projects.haskell.org/diagrams/manual/diagrams-manual.html#delayed-composition
describes a similar trick, using lists instead of Map.
-Brent