summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2016-04-10 22:59:37 +0200
committerBen Gamari <ben@smart-cactus.org>2016-04-10 23:41:16 +0200
commit7443e5c8dae24b83f5f4975c7accce02b819029c (patch)
tree80d9030b79ca386636916fc9f7a2cdd629d437d0 /testsuite
parentad532ded871a9a5180388a2b7cdbdc26e053284c (diff)
downloadhaskell-7443e5c8dae24b83f5f4975c7accce02b819029c.tar.gz
Remove the instantiation check when deriving Generic(1)
Previously, deriving `Generic(1)` bailed out when attempting to instantiate visible type parameters (#5939), but this instantiation check was quite fragile and doesn't interact well with `-XTypeInType`. It has been decided that `Generic(1)` shouldn't be subjected to this check anyway, so it has been removed, and `gen_Generic_binds`'s machinery has been updated to substitute the type variables in a generated `Rep`/`Rep1` instance with the user-supplied type arguments. In addition, this also refactors `Condition` in `TcDeriv` a bit. Namely, since we no longer need `tc_args` to check any conditions, the `[Type]` component of `Condition` has been removed. Fixes #11732. Test Plan: ./validate Reviewers: goldfire, kosmikus, simonpj, bgamari, austin Reviewed By: simonpj, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2061 GHC Trac Issues: #5939, #11732
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/deriving/should_compile/T11732a.hs11
-rw-r--r--testsuite/tests/deriving/should_compile/T11732b.hs12
-rw-r--r--testsuite/tests/deriving/should_compile/T11732c.hs18
-rw-r--r--testsuite/tests/deriving/should_compile/T5939.hs14
-rw-r--r--testsuite/tests/deriving/should_compile/all.T4
-rw-r--r--testsuite/tests/generics/GenCannotDoRep0_0.stderr30
6 files changed, 69 insertions, 20 deletions
diff --git a/testsuite/tests/deriving/should_compile/T11732a.hs b/testsuite/tests/deriving/should_compile/T11732a.hs
new file mode 100644
index 0000000000..54e1582642
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T11732a.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeInType #-}
+module T11732a where
+
+import GHC.Generics
+
+data Proxy k (a :: k) deriving Generic1
+
+data family ProxyFam (a :: y) (b :: z)
+data instance ProxyFam k (a :: k) deriving Generic1
diff --git a/testsuite/tests/deriving/should_compile/T11732b.hs b/testsuite/tests/deriving/should_compile/T11732b.hs
new file mode 100644
index 0000000000..ba71ba5b30
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T11732b.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeInType #-}
+module T11732b where
+
+data P1 (a :: k) = MkP1 deriving Functor
+data P2 k (a :: k) = MkP2 deriving Functor
+
+data family P1Fam (x :: y)
+data family P2Fam (x :: y) (z :: w)
+data instance P1Fam (a :: k) deriving Functor
+data instance P2Fam k (a :: k) deriving Functor
diff --git a/testsuite/tests/deriving/should_compile/T11732c.hs b/testsuite/tests/deriving/should_compile/T11732c.hs
new file mode 100644
index 0000000000..e013383f22
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T11732c.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeInType #-}
+module T11732c where
+
+import Data.Kind
+
+class Cat k (cat :: k -> k -> *) where
+ catId :: cat a a
+ catComp :: cat b c -> cat a b -> cat a c
+
+instance Cat * (->) where
+ catId = id
+ catComp = (.)
+
+newtype Fun1 a b = Fun1 (a -> b) deriving (Cat k)
+newtype Fun2 a b = Fun2 (a -> b) deriving (Cat *)
diff --git a/testsuite/tests/deriving/should_compile/T5939.hs b/testsuite/tests/deriving/should_compile/T5939.hs
new file mode 100644
index 0000000000..30eda2c562
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T5939.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TypeFamilies #-}
+module T5939 where
+
+import GHC.Generics
+
+data T a = T a
+deriving instance Generic (T Bool)
+
+data family TFam a b c
+data instance TFam Int b c
+deriving instance Generic (TFam Int Bool c)
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index e62c50c218..d5401e6e5f 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -27,6 +27,7 @@ test('T4302', normal, compile, [''])
test('T4325', normal, compile, [''])
test('T4816', normal, compile, [''])
test('T4966', normal, compile, [''])
+test('T5939', normal, compile, [''])
test('drv-functor1', normal, compile, [''])
test('drv-functor2', normal, compile, [''])
@@ -65,3 +66,6 @@ test('T11174', normal, compile, [''])
test('T11416', normal, compile, [''])
test('T11396', normal, compile, [''])
test('T11357', normal, compile, [''])
+test('T11732a', normal, compile, [''])
+test('T11732b', normal, compile, [''])
+test('T11732c', normal, compile, [''])
diff --git a/testsuite/tests/generics/GenCannotDoRep0_0.stderr b/testsuite/tests/generics/GenCannotDoRep0_0.stderr
index e1292b8e7e..be649e0d46 100644
--- a/testsuite/tests/generics/GenCannotDoRep0_0.stderr
+++ b/testsuite/tests/generics/GenCannotDoRep0_0.stderr
@@ -1,24 +1,14 @@
-GenCannotDoRep0_0.hs:6:14: Warning:
+GenCannotDoRep0_0.hs:6:14: warning:
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
-GenCannotDoRep0_0.hs:13:45:
- Can't make a derived instance of ‘Generic Dynamic’:
- Constructor ‘Dynamic’ has existentials or constraints in its type
- Possible fix: use a standalone deriving declaration instead
- In the data declaration for ‘Dynamic’
+GenCannotDoRep0_0.hs:13:45: error:
+ • Can't make a derived instance of ‘Generic Dynamic’:
+ Constructor ‘Dynamic’ has existentials or constraints in its type
+ Possible fix: use a standalone deriving declaration instead
+ • In the data declaration for ‘Dynamic’
-GenCannotDoRep0_0.hs:17:1:
- Can't make a derived instance of ‘Generic (P Int)’:
- P must not be instantiated; try deriving `P a' instead
- In the stand-alone deriving instance for ‘Generic (P Int)’
-
-GenCannotDoRep0_0.hs:26:1:
- Can't make a derived instance of ‘Generic (D Char Char)’:
- D must not be instantiated; try deriving `D Char b' instead
- In the stand-alone deriving instance for ‘Generic (D Char Char)’
-
-GenCannotDoRep0_0.hs:28:1:
- Can't make a derived instance of ‘Generic (D Int a)’:
- D must not have a datatype context
- In the stand-alone deriving instance for ‘Generic (D Int a)’
+GenCannotDoRep0_0.hs:28:1: error:
+ • Can't make a derived instance of ‘Generic (D Int a)’:
+ D must not have a datatype context
+ • In the stand-alone deriving instance for ‘Generic (D Int a)’