diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-06-25 15:48:37 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-06-25 15:49:39 +0100 |
commit | 9a348640c5ddd63c3385d3722fb3ade38013a148 (patch) | |
tree | 3ef2406dcec0d237380b2e278a69cbfefded8375 /testsuite | |
parent | 4d1316a56cb2e763ef6b47f95e529ae799b4c5ff (diff) | |
download | haskell-9a348640c5ddd63c3385d3722fb3ade38013a148.tar.gz |
Improve kind-checking for 'deriving' clauses
The main payload is in 'mk_functor_like_constraints' in
TcDeriv.inferConstraints.
This is moving towards a fix for Trac #10561
Diffstat (limited to 'testsuite')
6 files changed, 31 insertions, 15 deletions
diff --git a/testsuite/tests/deriving/should_compile/T10561.hs b/testsuite/tests/deriving/should_compile/T10561.hs new file mode 100644 index 0000000000..85acc516d9 --- /dev/null +++ b/testsuite/tests/deriving/should_compile/T10561.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE PolyKinds, DeriveFunctor, RankNTypes #-} + +module T10561 where + +-- Ultimately this should "Just Work", +-- but in GHC 7.10 it gave a Lint failure +-- For now (HEAD, Jun 2015) it gives a kind error message, +-- which is better than a crash + +newtype Compose f g a = Compose (f (g a)) deriving Functor + +{- +instance forall (f_ant :: k_ans -> *) + (g_anu :: * -> k_ans). + (Functor f_ant, Functor g_anu) => + Functor (Compose f_ant g_anu) where + fmap f_anv (T10561.Compose a1_anw) + = Compose (fmap (fmap f_anv) a1_anw) +-} diff --git a/testsuite/tests/deriving/should_compile/T10561.stderr b/testsuite/tests/deriving/should_compile/T10561.stderr new file mode 100644 index 0000000000..3a158ddb9a --- /dev/null +++ b/testsuite/tests/deriving/should_compile/T10561.stderr @@ -0,0 +1,5 @@ + +T10561.hs:10:52: error: + Couldn't match kind ‘k’ with ‘*’ + arising from the first field of ‘Compose’ (type ‘f (g a)’) + When deriving the instance for (Functor (Compose f g)) diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index e16d8f5432..a01a5149b2 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -53,4 +53,5 @@ test('T9069', normal, compile, ['']) test('T9359', normal, compile, ['']) test('T4896', normal, compile, ['']) test('T7947', extra_clean(['T7947a.o', 'T7947a.hi', 'T7947b.o', 'T7947b.hi']), multimod_compile, ['T7947', '-v0']) +test('T10561', normal, compile_fail, ['']) diff --git a/testsuite/tests/deriving/should_fail/T9071.stderr b/testsuite/tests/deriving/should_fail/T9071.stderr index 3a09c8ecd5..c2dccbd28f 100644 --- a/testsuite/tests/deriving/should_fail/T9071.stderr +++ b/testsuite/tests/deriving/should_fail/T9071.stderr @@ -1,10 +1,7 @@ [1 of 2] Compiling T9071a ( T9071a.hs, T9071a.o ) [2 of 2] Compiling T9071 ( T9071.hs, T9071.o ) -T9071.hs:7:37: - No instance for (Functor Mu) +T9071.hs:7:37: error: + Couldn't match kind ‘* -> *’ with ‘*’ arising from the first field of ‘F’ (type ‘Mu (K a)’) - Possible fix: - use a standalone 'deriving instance' declaration, - so you can specify the instance context yourself When deriving the instance for (Functor F) diff --git a/testsuite/tests/deriving/should_fail/T9071_2.stderr b/testsuite/tests/deriving/should_fail/T9071_2.stderr index 65ba471c40..f618343a7a 100644 --- a/testsuite/tests/deriving/should_fail/T9071_2.stderr +++ b/testsuite/tests/deriving/should_fail/T9071_2.stderr @@ -1,8 +1,5 @@ -T9071_2.hs:7:40: - No instance for (Functor K1) +T9071_2.hs:7:40: error: + Couldn't match kind ‘* -> *’ with ‘*’ arising from the first field of ‘F1’ (type ‘Mu (K1 a)’) - Possible fix: - use a standalone 'deriving instance' declaration, - so you can specify the instance context yourself When deriving the instance for (Functor F1) diff --git a/testsuite/tests/typecheck/should_fail/T9305.stderr b/testsuite/tests/typecheck/should_fail/T9305.stderr index c908a562ae..e7c761ef46 100644 --- a/testsuite/tests/typecheck/should_fail/T9305.stderr +++ b/testsuite/tests/typecheck/should_fail/T9305.stderr @@ -1,8 +1,5 @@ -T9305.hs:8:48: - No instance for (Functor F) +T9305.hs:8:48: error: + Couldn't match kind ‘* -> *’ with ‘*’ arising from the first field of ‘EventF’ (type ‘F (Event a)’) - Possible fix: - use a standalone 'deriving instance' declaration, - so you can specify the instance context yourself When deriving the instance for (Functor EventF) |