Enhance kind inference for data family instances
This commit improves kind inference for data family instances by kind-checking the constructors, for H98 and newtype declarations (ONLY), as well as kind-checking the result kind signature (when using GADT syntax). This fixes #25611. Typechecker changes: In `tcDataFamInstHeader`, we now kind-check the constructors using `kcConDecls`, for H98-style decls and newtype decls ONLY. See Note [Kind inference for data family instances]. Testsuite changes: - The T25611{a,b,c,d} tests test the new kind inference implementation. - a,b: infer result kind from constructors (H98 case) - c: renamed version of test UnliftedNewtypesUnassociatedFamilyFail, which now passes - d: GADT case, checking that we don't infer overly rigid kinds when kind-checking the constructors in data family instances. - DataInstanceKindsDefaults tests defaulting data instance kinds without UnliftedNewtypes or UnliftedDatatypes, as outlined in Note [Defaulting result kind of newtype/data family instance]. Also a few notes are updated to reflect the changes. Co-authored-by:default avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
Showing
- compiler/GHC/Tc/Gen/HsType.hs 12 additions, 5 deletionscompiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/TyCl.hs 17 additions, 11 deletionscompiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs 69 additions, 30 deletionscompiler/GHC/Tc/TyCl/Instance.hs
- testsuite/tests/indexed-types/should_compile/DataInstanceKindsDefaults.hs 26 additions, 0 deletions...indexed-types/should_compile/DataInstanceKindsDefaults.hs
- testsuite/tests/indexed-types/should_compile/T25611a.hs 17 additions, 0 deletionstestsuite/tests/indexed-types/should_compile/T25611a.hs
- testsuite/tests/indexed-types/should_compile/T25611b.hs 16 additions, 0 deletionstestsuite/tests/indexed-types/should_compile/T25611b.hs
- testsuite/tests/indexed-types/should_compile/T25611c.hs 8 additions, 2 deletionstestsuite/tests/indexed-types/should_compile/T25611c.hs
- testsuite/tests/indexed-types/should_compile/T25611d.hs 38 additions, 0 deletionstestsuite/tests/indexed-types/should_compile/T25611d.hs
- testsuite/tests/indexed-types/should_compile/all.T 5 additions, 0 deletionstestsuite/tests/indexed-types/should_compile/all.T
- testsuite/tests/typecheck/should_fail/UnliftedNewtypesFamilyKindFail2.stderr 8 additions, 0 deletions...echeck/should_fail/UnliftedNewtypesFamilyKindFail2.stderr
- testsuite/tests/typecheck/should_fail/UnliftedNewtypesInstanceFail.stderr 5 additions, 0 deletions...typecheck/should_fail/UnliftedNewtypesInstanceFail.stderr
- testsuite/tests/typecheck/should_fail/UnliftedNewtypesUnassociatedFamilyFail.stderr 0 additions, 32 deletions...should_fail/UnliftedNewtypesUnassociatedFamilyFail.stderr
- testsuite/tests/typecheck/should_fail/all.T 0 additions, 1 deletiontestsuite/tests/typecheck/should_fail/all.T
Loading
Please register or sign in to comment