Add Substitute instances for ExtShape and ExtDimSize.
Some more work.

Certain recursive functions now type-check!