Add a typevar substitution function

This allows one to pattern match against one
symbolic type, than substitute the matches
into another