summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_compile
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-06-25 15:48:37 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2015-06-25 15:49:39 +0100
commit9a348640c5ddd63c3385d3722fb3ade38013a148 (patch)
tree3ef2406dcec0d237380b2e278a69cbfefded8375 /testsuite/tests/deriving/should_compile
parent4d1316a56cb2e763ef6b47f95e529ae799b4c5ff (diff)
downloadhaskell-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/tests/deriving/should_compile')
-rw-r--r--testsuite/tests/deriving/should_compile/T10561.hs19
-rw-r--r--testsuite/tests/deriving/should_compile/T10561.stderr5
-rw-r--r--testsuite/tests/deriving/should_compile/all.T1
3 files changed, 25 insertions, 0 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, [''])