I was trying to add some "derive" functionality by representing datatypes, say "a" with some generic datatype, say "rep (a)". However, for a generic function to work on a value of type "rep (a)", we need the type information for the actual values stored in the original value of type "a" (which are copied into the value of type "rep (a)").
It's much like trying to print a heterogeneous list, generically. I need to supply the print function with the actual type of every element. Thus I think I probably need the type info to be a template, so that the user can instantiate it for every datatype they want to be generic.
Am I on the right track? Are there other ways of doing it?