diff options
author | RyanGlScott <ryan.gl.scott@gmail.com> | 2016-04-11 02:53:23 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-04-11 02:53:24 +0200 |
commit | aadde2b90817c577336da0d4a10ea47551d60c7e (patch) | |
tree | 09840461f8c98180b486b34f68d8c97a210113bb /testsuite/tests/deriving | |
parent | 8b57cac5974c9fffccbcae3104b5b5d18760749e (diff) | |
download | haskell-aadde2b90817c577336da0d4a10ea47551d60c7e.tar.gz |
Deriving Functor-like classes should unify kind variables
While the deriving machinery always unifies the kind of the typeclass
argument with the kind of the datatype, this proves not to be sufficient
to produce well kinded instances for some poly-kinded datatypes. For
example:
```
newtype Compose (f :: k2 -> *) (g :: k1 -> k2) (a :: k1)
= Compose (f (g a)) deriving Functor
```
would fail because only `k1` would get unified with `*`, causing the
following
ill kinded instance to be generated:
```
instance (Functor (f :: k2 -> *), Functor (g :: * -> k2)) =>
Functor (Compose f g) where ...
```
To prevent this, we need to take the subtypes and unify their kinds with
`* -> *`.
Fixes #10524 for good.
Test Plan: ./validate
Reviewers: simonpj, hvr, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2097
GHC Trac Issues: #10524, #10561
Diffstat (limited to 'testsuite/tests/deriving')
-rw-r--r-- | testsuite/tests/deriving/should_compile/T10561.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_compile/T10561.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_compile/all.T | 2 |
3 files changed, 1 insertions, 22 deletions
diff --git a/testsuite/tests/deriving/should_compile/T10561.hs b/testsuite/tests/deriving/should_compile/T10561.hs index 85acc516d9..632863270c 100644 --- a/testsuite/tests/deriving/should_compile/T10561.hs +++ b/testsuite/tests/deriving/should_compile/T10561.hs @@ -2,18 +2,4 @@ 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 deleted file mode 100644 index c74967ff43..0000000000 --- a/testsuite/tests/deriving/should_compile/T10561.stderr +++ /dev/null @@ -1,7 +0,0 @@ - -T10561.hs:10:52: error: - • Couldn't match kind ‘k’ with ‘*’ - arising from the first field of ‘Compose’ (type ‘f (g a)’) - ‘k’ is a rigid type variable bound by - the deriving clause for ‘Functor (Compose f g)’ at T10561.hs:10:52 - • 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 d5401e6e5f..cfbb977abe 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -56,7 +56,7 @@ 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, ['']) +test('T10561', normal, compile, ['']) test('T10487', extra_clean(['T10487_M.o', 'T10487_M.hi']), multimod_compile, ['T10487', '-v0']) test('T10524', normal, compile, ['']) test('T11148', normal, run_command, |