Work on type-checking existentially quantified shapes.
Rename combineResTypes to generaliseResTypes.