ImpredicativeTypes even more broken than usual
I don't have the latest version of GHC, trying to derive `Functor A` and `Foldable A` is fine but when I derive `Traversable A` in the attachment Error.hs:
```hs
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, ImpredicativeTypes #-}
import Data.Functor (Functor)
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
data A a = A
deriving (Functor, Foldable, Traversable)
```
GHC barks at me (verbose log attached):
```hs
/tmp/Error.hs:8:32: error:
• Couldn't match type ‘forall a1. A a1’ with ‘A b’
Expected type: f (A b)
Actual type: f (forall a. A a)
• In the expression: pure A
In an equation for ‘traverse’: traverse f A = pure A
When typechecking the code for ‘traverse’
in a derived instance for ‘Traversable A’:
To see the code I am typechecking, use -ddump-deriv
In the instance declaration for ‘Traversable A’
• Relevant bindings include
f :: a -> f b (bound at /tmp/Error.hs:8:32)
traverse :: (a -> f b) -> A a -> f (A b)
(bound at /tmp/Error.hs:8:32)
```
With `-ddump-deriv` we get this (unqualified) instance:
```hs
instance Traversable A where
traverse f_a2Le A = pure A
```
which by itself causes the same problem in the attachment Error2.hs:
```hs
{-# LANGUAGE DeriveFunctor, DeriveFoldable, ImpredicativeTypes #-}
import Data.Functor (Functor)
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
data A a = A
deriving (Functor, Foldable)
instance Traversable A where
traverse f A = pure A
```
Works fine in GHC-7.10.2 and GHC-7.10.0.20150316 and GHC-7.4 (with some additional imports), is this an `ImpredicativeTypes` regression?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 7.11 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"ImpredicativeTypes cause trouble (affects deriving of Traversable)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.11","keywords":["ImpredicativeTypes"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I don't have the latest version of GHC, trying to derive `Functor A` and `Foldable A` is fine but when I derive `Traversable A` in the attachment Error.hs:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, ImpredicativeTypes #-}\r\n\r\nimport Data.Functor (Functor)\r\nimport Data.Foldable (Foldable)\r\nimport Data.Traversable (Traversable)\r\n\r\ndata A a = A\r\n deriving (Functor, Foldable, Traversable)\r\n}}}\r\n\r\nGHC barks at me (verbose log attached):\r\n\r\n{{{#!hs\r\n/tmp/Error.hs:8:32: error:\r\n • Couldn't match type ‘forall a1. A a1’ with ‘A b’\r\n Expected type: f (A b)\r\n Actual type: f (forall a. A a)\r\n • In the expression: pure A\r\n In an equation for ‘traverse’: traverse f A = pure A\r\n When typechecking the code for ‘traverse’\r\n in a derived instance for ‘Traversable A’:\r\n To see the code I am typechecking, use -ddump-deriv\r\n In the instance declaration for ‘Traversable A’\r\n • Relevant bindings include\r\n f :: a -> f b (bound at /tmp/Error.hs:8:32)\r\n traverse :: (a -> f b) -> A a -> f (A b)\r\n (bound at /tmp/Error.hs:8:32)\r\n}}}\r\n\r\nWith `-ddump-deriv` we get this (unqualified) instance:\r\n\r\n{{{#!hs\r\n instance Traversable A where\r\n traverse f_a2Le A = pure A\r\n}}}\r\n\r\nwhich by itself causes the same problem in the attachment Error2.hs:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DeriveFunctor, DeriveFoldable, ImpredicativeTypes #-}\r\n\r\nimport Data.Functor (Functor)\r\nimport Data.Foldable (Foldable)\r\nimport Data.Traversable (Traversable)\r\n\r\ndata A a = A\r\n deriving (Functor, Foldable)\r\n\r\ninstance Traversable A where\r\n traverse f A = pure A\r\n}}}\r\n\r\nWorks fine in GHC-7.10.2 and GHC-7.10.0.20150316 and GHC-7.4 (with some additional imports), is this an `ImpredicativeTypes` regression?","type_of_failure":"OtherFailure","blocking":[]} -->
issue