Note [Kind checking recursive type and class declarations]
Before we can type-check the decls, we must kind check them. This is done by establishing an "initial kind", which is a rather uninformed guess at a tycon's kind (by counting arguments, mainly) and then using this initial kind for recursive occurrences. The initial kind is stored in exactly the same way during kind-checking as it is during type-checking (Note [Type checking recursive type and class declarations]): in the *local* environment, with ATcTyCon. But we still must store *something* in the *global* environment. Even though we discard the result of kind-checking, we sometimes need to produce error messages. These error messages will want to refer to the tycons being checked, except that they don't exist yet, and it would be Terribly Annoying to get the error messages to refer back to HsSyn. So we create a TcTyCon and put it in the global env. This tycon can print out its name and knows its kind, but any other action taken on it will panic. Note that TcTyCons are *not* knot-tied, unlike the rather valid but knot-tied ones that occur during type-checking.
References 0
This Note does not link to any other.
Referenced by 2
- CUSKs and PolyKinds GHC.Tc.TyCl
- Type checking recursive type and class declarations GHC.Tc.TyCl