I thought of a different way to do it that would stay encapsulated in type_as_string, so this is the version I'm going to check in. Tested x86_64-pc-linux-gnu, applying to trunk.