Manuel M. T. Chakravarty writes:
> The canonical approach is to define an internal data
> structure that represents C++ code, then let your mutator
> functions generate values of that data type (instead of
> strings), and finally pretty print values of this C++ data
> structure. That's cleaner and more flexible than the ++
> cascades (or the show equivalent).
>
> Depending on how restricted and/or idiomatic the generate
> C++ code is, it makes sense to not have a data structure
> that can represent arbitrary C++ programs, but only a subset
> that is relevant for the code generation task at hand. So,
> you might want functions like
>
> mutatorDef :: ... -> AbstractCPlusPlus
>
> prettyPrintACPP :: AbstractCPlusPlus -> String
Thanks for the clear description (and to Julian Seward who also
suggested such an approach). Alfter playing with the code a little
more, I had actually already started down this approach. The tricky
bit will be, as you say, defining a data structure that is "just"
general enough.
Tim