typeKind is quadratic
While pondering D3998, I realized that any computation of a type's kind should be careful in the presence of nested
AppTys. And, to my horror, I realized that GHC's very own
typeKind isn't! That is, if you have the type
a b c d e, GHC will take a quadratic (or worse -- haven't benchmarked) amount of time computing its kind.
This can be easily fixed by looking for nested
AppTys and using
piResultTys, instead of repeated uses of
piResultTy (as is currently done).
NB: This was not discovered through witnessing poor performance, but it does seem like very low-hanging compiler-performance fruit.