Could anyone explain or guess the motivation behind the limit on data type promotion discussed in section 7.9.2 of the GHC user guide?
The following restrictions apply to promotion:
- We only promote datatypes whose kinds are of the form
* -> ... -> * -> *
. In particular, we do not promote higher-kinded datatypes such asdata Fix f = In (f (Fix f))
, or datatypes whose kinds involve promoted types such asVec :: * -> Nat -> *
.
In particular, I am interested in the last bit about promoted types such as Vec :: * -> Nat -> *
. Promoting some types like that seems natural. I ran into it pretty quickly while trying to convert one of my libraries to use specific promoted kinds for the various phantom types instead of using kind *
for everything, to provide better documentation and such.
Oftentimes the reasons for compiler limitations like these jump out at you with a little thinking, but I'm not seeing this one. So I'm wondering if it comes in the category of "not needed yet, so we didn't build it" or "that's impossible/undecidable/destroys inference."