I have come up with an idea for how to "solve" the matrix problem but it ain't pretty. As long as you don't want to compile something symbolic into a concrete proc you could build whatever kinds of types using composition. A symbolic matrix, a symbolic tree or whatever. But as soon as you want to compile the symbolic AST to Nim code you're stuck basically as my generate macro has no way of knowing what kind of type to construct that has this symbolic expression as a field (Without some really advanced typed macros perhaps).
So how can we solve this? By requiring every type that you want to compile to have a `compile` macro or something. There should of course be helper macros for common use cases (for example compiling a seq of symbolic expressions). A symbolic matrix could then be compiled into an Arraymancer tensor for example. Is it complicated? Yes! Is it demanding a lot from the plugin developers? Yes, but they get to learn more about macros ;). Is this idea completely whacko or could it work and be maintainable? Adding a field to a custom type shouldn't require them to change a lot in the compile macro for example.