Simultaneously substitute type variables

This one falls into the category of "it's amazing it hasn't broken already". Also, it turns out `lens` is a great source of type-class related test cases :)

The fix is to substitute all type vars simultaneously, since the substitutions may not commute.

Resolves #652. Tested with `test-everything`.