the bug was that replaceTC was only checking if the type being examined exactly matched the type being replaced. To be correct it also needed to recursively check for and replace instances of the type being replaced inside type constructors