On Fri, May 18, 2012 at 07:58:03AM +1000, Stuart Hungerford wrote:
> Hi,
>
> Newbie time again. I'm planning to load a collection of Diagrams
> attributes from a JSON file and parsing those values into some kind of
> Haskell data structure. I'd like to be able to pass that data
> structure to a function that can apply all the attributes it contains
> to a Diagram.
>
> In other languages the data structure would be a heterogeneous map
> with string keys,
That's (essentially) what is already provided by the Style type --
except all wrapped up in a nice type-safe way. See
http://hackage.haskell.org/packages/archive/diagrams-core/0.5.0.1/doc/html/Graphics-Rendering-Diagrams-Style.html
> I've looked at the
> Diagrams.Attributes module but not expert enough yet to see the
> opportunities there.
Don't worry, it not your expertise at issue -- Diagrams.Attributes
just defines some standard attributes, but the framework for
attributes and styles itself is defined in the diagrams-core package
(in the module I linked above).
I expect you should be able to use the Style type to do exactly what
you're talking about doing. If you have any trouble figuring out how
to do it don't hesitate to ask. Perhaps this is also an area in which
the user manual could be improved/extended?
-Brent