Type/data family instances in kind checking
See
* [Artem's blog post](https://serokell.io/blog/dependency-analysis-haskell) about this stuff; it's very helpful.
* [This wiki page](https://gitlab.haskell.org/ghc/ghc/-/wikis/interleaving-type-instance-checking), written in response to this ticket
* [This later wiki page](https://gitlab.haskell.org/ghc/ghc/-/wikis/Type-&-Class-Dependency-Analysis), also written in response to this ticket
In `TcEnv.hs` there is a note AFamDataCon: not promoting data family constructors. It states that we can't use a promoted data family instance constructor because we would have to interleave the checking of instances and data types. But with the fix of #11348, we now do exactly this. In the example from the note
```hs
data family T a
data instance T Int = MkT
data Proxy (a :: k)
data S = MkS (Proxy 'MkT)
```
-ddump-rn-trace shows these groups
```
rnTycl dependency analysis made groups
[[data family T a_apG]
[]
[data instance T Int = MkT],
[data Proxy (a_apF :: k_apE)]
[]
[],
[data S = MkS (Proxy MkT)]
[]
[]]
```
That's to say, the instance `T Int` will in fact be checked before `S`. So let's remove this restriction.
See also:
* #11348
* #12643 (deriving)
* #12239
* #14668
* #16693
* #16410
* #16448
* #19611
* #20875
* #21172
* #22257
* #23496 (deriving)
* #25238
* #25834
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.1 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #11348 |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Promote data family instance constructors","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[11348],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"In `TcEnv.hs` there is a note AFamDataCon: not promoting data family constructors. It states that we can't use a promoted data family instance constructor because we would have to interleave the checking of instances and data types. But with the fix of #11348, we now do exactly this. In the example from the note\r\n\r\n{{{#!hs\r\ndata family T a\r\ndata instance T Int = MkT\r\ndata Proxy (a :: k)\r\ndata S = MkS (Proxy 'MkT)\r\n}}}\r\n\r\n-ddump-rn-trace shows these groups\r\n\r\n{{{\r\nrnTycl dependency analysis made groups\r\n [[data family T a_apG]\r\n []\r\n [data instance T Int = MkT],\r\n [data Proxy (a_apF :: k_apE)]\r\n []\r\n [],\r\n [data S = MkS (Proxy MkT)]\r\n []\r\n []]\r\n}}}\r\n\r\nThat's to say, the instance `T Int` will in fact be checked before `S`. So let's remove this restriction.","type_of_failure":"OtherFailure","blocking":[]} -->
issue