From 62ed6957463a9c0f711ea698d7ed4371e00fb122 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Wed, 2 Dec 2020 10:27:47 +0000 Subject: Fix kind inference for data types. Again. This patch fixes several aspects of kind inference for data type declarations, especially data /instance/ declarations Specifically 1. In kcConDecls/kcConDecl make it clear that the tc_res_kind argument is only used in the H98 case; and in that case there is no result kind signature; and hence no need for the disgusting splitPiTys in kcConDecls (now thankfully gone). The GADT case is a bit different to before, and much nicer. This is what fixes #18891. See Note [kcConDecls: kind-checking data type decls] 2. Do not look at the constructor decls of a data/newtype instance in tcDataFamInstanceHeader. See GHC.Tc.TyCl.Instance Note [Kind inference for data family instances]. This was a new realisation that arose when doing (1) This causes a few knock-on effects in the tests suite, because we require more information than before in the instance /header/. New user-manual material about this in "Kind inference in data type declarations" and "Kind inference for data/newtype instance declarations". 3. Minor improvement in kcTyClDecl, combining GADT and H98 cases 4. Fix #14111 and #8707 by allowing the header of a data instance to affect kind inferece for the the data constructor signatures; as described at length in Note [GADT return types] in GHC.Tc.TyCl This led to a modest refactoring of the arguments (and argument order) of tcConDecl/tcConDecls. 5. Fix #19000 by inverting the sense of the test in new_locs in GHC.Tc.Solver.Canonical.canDecomposableTyConAppOK. --- testsuite/tests/patsyn/should_fail/T15685.stderr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'testsuite/tests/patsyn') diff --git a/testsuite/tests/patsyn/should_fail/T15685.stderr b/testsuite/tests/patsyn/should_fail/T15685.stderr index e081453659..723d0fcff3 100644 --- a/testsuite/tests/patsyn/should_fail/T15685.stderr +++ b/testsuite/tests/patsyn/should_fail/T15685.stderr @@ -1,13 +1,13 @@ T15685.hs:13:24: error: - • Could not deduce: a ~ [k0] - from the context: as ~ (a1 : as1) + • Could not deduce: k ~ [k0] + from the context: as ~ (a : as1) bound by a pattern with constructor: - Here :: forall {a1} (f :: a1 -> *) (a2 :: a1) (as :: [a1]). - f a2 -> NS f (a2 : as), + Here :: forall {k} (f :: k -> *) (a :: k) (as :: [k]). + f a -> NS f (a : as), in a pattern synonym declaration at T15685.hs:13:19-26 - ‘a’ is a rigid type variable bound by + ‘k’ is a rigid type variable bound by the inferred type of HereNil :: NS f as at T15685.hs:13:9-15 Possible fix: add a type signature for ‘HereNil’ -- cgit v1.2.1