summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Pedro Magalhaes <jpm@cs.ox.ac.uk>2012-06-21 12:13:33 +0100
committerJose Pedro Magalhaes <jpm@cs.ox.ac.uk>2012-06-21 12:13:49 +0100
commit686628d242e497a746d6272247445def6b6a2485 (patch)
tree772364e12390647df0a2bfae0b863c8daea60ef8
parent9d3bf7df0d059cb4b5273edd73a0eb9bb0a856eb (diff)
downloadhaskell-686628d242e497a746d6272247445def6b6a2485.tar.gz
Add tests for deriving Generic1
Most of these tests were written by Nicolas Frisby.
-rw-r--r--testsuite/tests/generics/GFunctor/GFunctor.hs54
-rw-r--r--testsuite/tests/generics/GFunctor/GFunctor1.stdout1
-rw-r--r--testsuite/tests/generics/GFunctor/Main.hs26
-rw-r--r--testsuite/tests/generics/GFunctor/Makefile3
-rw-r--r--testsuite/tests/generics/GFunctor/test.T4
-rw-r--r--testsuite/tests/generics/GMap/GMap.hs41
-rw-r--r--testsuite/tests/generics/GMap/GMap1.stdout3
-rw-r--r--testsuite/tests/generics/GMap/Main.hs27
-rw-r--r--testsuite/tests/generics/GMap/Makefile3
-rw-r--r--testsuite/tests/generics/GMap/test.T4
-rw-r--r--testsuite/tests/generics/GenCanDoRep1.hs20
-rw-r--r--testsuite/tests/generics/GenCanDoRep1_0.hs32
-rw-r--r--testsuite/tests/generics/GenCannotDoRep0.hs23
-rw-r--r--testsuite/tests/generics/GenCannotDoRep0.stderr28
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_0.hs9
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_0.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_1.hs8
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_1.stderr8
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_2.hs13
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_2.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_3.hs11
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_3.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_4.hs8
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_4.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_5.hs9
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_5.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_6.hs9
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_6.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_7.hs11
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_7.stderr5
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_8.hs12
-rw-r--r--testsuite/tests/generics/GenCannotDoRep1_8.stderr5
-rw-r--r--testsuite/tests/generics/GenDerivOutput.hs9
-rw-r--r--testsuite/tests/generics/GenDerivOutput.stderr129
-rw-r--r--testsuite/tests/generics/GenDerivOutput1_0.hs8
-rw-r--r--testsuite/tests/generics/GenDerivOutput1_0.stderr66
-rw-r--r--testsuite/tests/generics/GenDerivOutput1_1.hs26
-rw-r--r--testsuite/tests/generics/GenDerivOutput1_1.stderr351
-rw-r--r--testsuite/tests/generics/GenShouldFail1_0.hs11
-rw-r--r--testsuite/tests/generics/GenShouldFail1_0.stderr5
-rw-r--r--testsuite/tests/generics/all.T16
-rw-r--r--testsuite/tests/ghci.debugger/scripts/break006.stderr4
-rw-r--r--testsuite/tests/ghci.debugger/scripts/print019.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T5095.stderr3
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail072.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail133.stderr2
46 files changed, 1024 insertions, 17 deletions
diff --git a/testsuite/tests/generics/GFunctor/GFunctor.hs b/testsuite/tests/generics/GFunctor/GFunctor.hs
new file mode 100644
index 0000000000..0044339986
--- /dev/null
+++ b/testsuite/tests/generics/GFunctor/GFunctor.hs
@@ -0,0 +1,54 @@
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE DefaultSignatures #-}
+
+module GFunctor (
+ -- * Generic Functor class
+ GFunctor(..)
+ ) where
+
+
+import GHC.Generics
+
+--------------------------------------------------------------------------------
+-- Generic fmap
+--------------------------------------------------------------------------------
+
+class GFunctor' f where
+ gmap' :: (a -> b) -> f a -> f b
+
+instance GFunctor' U1 where
+ gmap' _ U1 = U1
+
+instance GFunctor' Par1 where
+ gmap' f (Par1 a) = Par1 (f a)
+
+instance GFunctor' (K1 i c) where
+ gmap' _ (K1 a) = K1 a
+
+instance (GFunctor f) => GFunctor' (Rec1 f) where
+ gmap' f (Rec1 a) = Rec1 (gmap f a)
+
+instance (GFunctor' f) => GFunctor' (M1 i c f) where
+ gmap' f (M1 a) = M1 (gmap' f a)
+
+instance (GFunctor' f, GFunctor' g) => GFunctor' (f :+: g) where
+ gmap' f (L1 a) = L1 (gmap' f a)
+ gmap' f (R1 a) = R1 (gmap' f a)
+
+instance (GFunctor' f, GFunctor' g) => GFunctor' (f :*: g) where
+ gmap' f (a :*: b) = gmap' f a :*: gmap' f b
+
+instance (GFunctor f, GFunctor' g) => GFunctor' (f :.: g) where
+ gmap' f (Comp1 x) = Comp1 (gmap (gmap' f) x)
+
+
+class GFunctor f where
+ gmap :: (a -> b) -> f a -> f b
+ default gmap :: (Generic1 f, GFunctor' (Rep1 f))
+ => (a -> b) -> f a -> f b
+ gmap f = to1 . gmap' f . from1
+
+-- Base types instances
+instance GFunctor Maybe
+instance GFunctor []
diff --git a/testsuite/tests/generics/GFunctor/GFunctor1.stdout b/testsuite/tests/generics/GFunctor/GFunctor1.stdout
new file mode 100644
index 0000000000..966a02092e
--- /dev/null
+++ b/testsuite/tests/generics/GFunctor/GFunctor1.stdout
@@ -0,0 +1 @@
+(D0,D1 {d11 = 'q', d12 = D0},D1 {d11 = 3.14, d12 = D0})
diff --git a/testsuite/tests/generics/GFunctor/Main.hs b/testsuite/tests/generics/GFunctor/Main.hs
new file mode 100644
index 0000000000..7d0a3df636
--- /dev/null
+++ b/testsuite/tests/generics/GFunctor/Main.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module Main where
+
+import GHC.Generics hiding (C, D)
+import GFunctor
+
+-- We should be able to generate a generic representation for these types
+data D a = D0 | D1 { d11 :: a, d12 :: (D a) }
+ deriving (Show, Generic, Generic1)
+
+-- Example values
+d0 :: D Char
+d0 = D0
+d1 = D1 (Just 'p') D0
+
+d2 :: (Fractional a) => D (a,a)
+d2 = D1 (3,0.14) D0
+
+-- Generic instances
+instance GFunctor D
+
+-- Tests
+main = print ( gmap undefined d0 :: D ()
+ , gmap (const 'q') d1
+ , gmap (\(a,b) -> a + b) d2 :: D Float)
diff --git a/testsuite/tests/generics/GFunctor/Makefile b/testsuite/tests/generics/GFunctor/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/generics/GFunctor/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/generics/GFunctor/test.T b/testsuite/tests/generics/GFunctor/test.T
new file mode 100644
index 0000000000..7018d8ffed
--- /dev/null
+++ b/testsuite/tests/generics/GFunctor/test.T
@@ -0,0 +1,4 @@
+setTestOpts(only_compiler_types(['ghc']))
+
+test('GFunctor1', extra_clean(['GFunctor.hi', 'GFunctor.o', 'Main.hi', 'Main.o']),
+ multimod_compile_and_run, ['Main', '']) \ No newline at end of file
diff --git a/testsuite/tests/generics/GMap/GMap.hs b/testsuite/tests/generics/GMap/GMap.hs
new file mode 100644
index 0000000000..e7d57dea70
--- /dev/null
+++ b/testsuite/tests/generics/GMap/GMap.hs
@@ -0,0 +1,41 @@
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE DefaultSignatures #-}
+
+module GMap (
+ -- * Generic map class
+ GMap(..)
+ ) where
+
+
+import GHC.Generics
+
+--------------------------------------------------------------------------------
+-- Generic map
+--------------------------------------------------------------------------------
+
+class GMap t where
+ gmap :: (a -> b) -> t a -> t b
+ default gmap :: (Generic1 t, GMap (Rep1 t)) => (a -> b) -> t a -> t b
+ gmap f = to1 . gmap f . from1
+
+instance GMap Par1 where gmap f (Par1 x) = Par1 $ f x
+instance GMap f => GMap (Rec1 f) where gmap f (Rec1 x) = Rec1 $ gmap f x
+
+instance GMap U1 where gmap _ U1 = U1
+
+instance GMap (K1 i c) where gmap _ (K1 x) = K1 x
+
+instance (GMap a) => GMap (M1 i d a) where gmap f (M1 x) = M1 $ gmap f x
+
+instance (GMap a, GMap b) => GMap (a :+: b) where
+ gmap f (L1 x) = L1 $ gmap f x
+ gmap f (R1 x) = R1 $ gmap f x
+
+instance (GMap a, GMap b) => GMap (a :*: b) where
+ gmap f (x :*: y) = gmap f x :*: gmap f y
+
+-- Base types instances
+instance GMap [] where gmap = map
+instance GMap Maybe where gmap = fmap
+instance GMap ((,) a) where gmap f ~(x, y) = (x, f y)
diff --git a/testsuite/tests/generics/GMap/GMap1.stdout b/testsuite/tests/generics/GMap/GMap1.stdout
new file mode 100644
index 0000000000..f24d682c7c
--- /dev/null
+++ b/testsuite/tests/generics/GMap/GMap1.stdout
@@ -0,0 +1,3 @@
+D0
+D1 {d11 = True, d12 = D0}
+D1 {d11 = 3, d12 = D0}
diff --git a/testsuite/tests/generics/GMap/Main.hs b/testsuite/tests/generics/GMap/Main.hs
new file mode 100644
index 0000000000..0d44621a2c
--- /dev/null
+++ b/testsuite/tests/generics/GMap/Main.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module Main where
+
+import GHC.Generics (Generic1)
+import GMap
+
+-- We should be able to generate a generic representation for these types
+data D a = D0 | D1 { d11 :: a, d12 :: (D a) } deriving (Show, Generic1)
+
+-- Example values
+d0 :: D Char
+d0 = D0
+d1 = D1 (Just 'p') D0
+
+d2 :: D (Int,Float)
+d2 = D1 (3,0.14) D0
+
+-- Generic instances
+instance GMap D
+
+-- Tests
+main = do
+ print $ gmap id d0
+ (let isJust (Just _) = True
+ isJust Nothing = False in print $ gmap isJust d1)
+ print $ gmap fst d2
diff --git a/testsuite/tests/generics/GMap/Makefile b/testsuite/tests/generics/GMap/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/generics/GMap/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/generics/GMap/test.T b/testsuite/tests/generics/GMap/test.T
new file mode 100644
index 0000000000..e83a2d857e
--- /dev/null
+++ b/testsuite/tests/generics/GMap/test.T
@@ -0,0 +1,4 @@
+setTestOpts(only_compiler_types(['ghc']))
+
+test('GMap1', extra_clean(['GMap.hi', 'GMap.o', 'Main.hi', 'Main.o']),
+ multimod_compile_and_run, ['Main', ''])
diff --git a/testsuite/tests/generics/GenCanDoRep1.hs b/testsuite/tests/generics/GenCanDoRep1.hs
new file mode 100644
index 0000000000..16ca81d88a
--- /dev/null
+++ b/testsuite/tests/generics/GenCanDoRep1.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE TypeOperators #-}
+
+module CanDoRep1 where
+
+import GHC.Generics (Generic, Generic1)
+
+
+-- We should be able to generate a generic representation for these types
+data A a
+ deriving Generic1
+
+data B a = B0 | B1
+ deriving Generic1
+
+data C a = C0 | C1 { c11 :: a, c12 :: (C a) }
+ deriving (Generic, Generic1)
+
+data (:*:) a b = a :*: b
+ deriving (Generic, Generic1)
diff --git a/testsuite/tests/generics/GenCanDoRep1_0.hs b/testsuite/tests/generics/GenCanDoRep1_0.hs
new file mode 100644
index 0000000000..db557d871b
--- /dev/null
+++ b/testsuite/tests/generics/GenCanDoRep1_0.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE TypeOperators #-}
+
+module GenCanDoRep1_0 where
+
+import GHC.Generics (Generic1(..), Rep1)
+
+
+-- We should be able to generate a generic representation for these types
+data B a
+ deriving Generic1
+
+data C a = C0 | C1
+ deriving Generic1
+
+data D a = D0 | D1 { d11 :: a, d12 :: (D a) }
+ deriving Generic1
+
+data (:*:) a b = a :*: b
+ deriving Generic1
+
+data E b a = E0 | E1 (E b b) deriving Generic1
+
+data F c b a = F (c, b, a) deriving Generic1
+data G c b a = G [(c, c, c, c, b, a)] deriving (Generic1, Show)
+
+
+data Odd a = Odd a (Even a) deriving Generic1
+data Even a = NilEven | Even a (Odd a) deriving Generic1
+
+data Odd' a = Odd' a (Even' a) deriving Generic1
+data Even' a = NilEven' | Even' a (Odd' a)
diff --git a/testsuite/tests/generics/GenCannotDoRep0.hs b/testsuite/tests/generics/GenCannotDoRep0.hs
index 5b4f93f94f..21beb8ae02 100644
--- a/testsuite/tests/generics/GenCannotDoRep0.hs
+++ b/testsuite/tests/generics/GenCannotDoRep0.hs
@@ -1,9 +1,30 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE DatatypeContexts #-}
module CannotDoRep0 where
-import GHC.Generics
+import GHC.Generics hiding (P, D)
-- We do not support existential quantification
data Dynamic = forall a. Dynamic a deriving Generic
+
+-- Partial instantiation of types is not allowed
+data P a = P a
+deriving instance Generic (P Int)
+
+-- This gets trickier for data families
+data family D a b
+data instance D Char b
+data instance (Show b) => D Int b
+data instance D () ()
+
+-- Bad: second argument is instantiated
+deriving instance Generic (D Char Char)
+-- Bad: has context
+deriving instance Generic (D Int a)
+-- Ok
+deriving instance Generic (D () ())
diff --git a/testsuite/tests/generics/GenCannotDoRep0.stderr b/testsuite/tests/generics/GenCannotDoRep0.stderr
index a12602d861..e222819e96 100644
--- a/testsuite/tests/generics/GenCannotDoRep0.stderr
+++ b/testsuite/tests/generics/GenCannotDoRep0.stderr
@@ -1,5 +1,23 @@
-
-GenCannotDoRep0.hs:9:45:
- Can't make a derived instance of `Generic Dynamic':
- Dynamic must be a vanilla data constructor
- In the data declaration for `Dynamic'
+
+GenCannotDoRep0.hs:6:14: Warning:
+ -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
+
+GenCannotDoRep0.hs:13:45:
+ Can't make a derived instance of `Generic Dynamic':
+ Dynamic must be a vanilla data constructor
+ In the data declaration for `Dynamic'
+
+GenCannotDoRep0.hs:17:1:
+ Can't make a derived instance of `Generic (P Int)':
+ P must not be instantiated; try deriving `P Int' instead
+ In the stand-alone deriving instance for `Generic (P Int)'
+
+GenCannotDoRep0.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.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)'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_0.hs b/testsuite/tests/generics/GenCannotDoRep1_0.hs
new file mode 100644
index 0000000000..3e3c409624
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_0.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE ExistentialQuantification #-}
+
+module CannotDoRep1_0 where
+
+import GHC.Generics
+
+-- We do not support existential quantification
+data Dynamic a = forall b. Dynamic b a deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_0.stderr b/testsuite/tests/generics/GenCannotDoRep1_0.stderr
new file mode 100644
index 0000000000..2e602af0e6
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_0.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_0.hs:9:49:
+ Can't make a derived instance of `Generic1 Dynamic':
+ Dynamic must be a vanilla data constructor
+ In the data declaration for `Dynamic'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_1.hs b/testsuite/tests/generics/GenCannotDoRep1_1.hs
new file mode 100644
index 0000000000..9ac8fc6cd1
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_1.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE DeriveGeneric, DatatypeContexts #-}
+
+module CannotDoRep1_1 where
+
+import GHC.Generics
+
+-- We do not support datatypes with context
+data (Show a) => Context a = Context a deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_1.stderr b/testsuite/tests/generics/GenCannotDoRep1_1.stderr
new file mode 100644
index 0000000000..df9f518c67
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_1.stderr
@@ -0,0 +1,8 @@
+
+GenCannotDoRep1_1.hs:1:29: Warning:
+ -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
+
+GenCannotDoRep1_1.hs:8:49:
+ Can't make a derived instance of `Generic1 Context':
+ Context must not have a datatype context
+ In the data declaration for `Context'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_2.hs b/testsuite/tests/generics/GenCannotDoRep1_2.hs
new file mode 100644
index 0000000000..cdbbed504b
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_2.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE GADTs #-}
+
+module CannotDoRep1_2 where
+
+import GHC.Generics
+
+-- We do not support GADTs
+data Term a where
+ Int :: Term Int
+
+deriving instance Generic1 Term
diff --git a/testsuite/tests/generics/GenCannotDoRep1_2.stderr b/testsuite/tests/generics/GenCannotDoRep1_2.stderr
new file mode 100644
index 0000000000..ffda5ffd2c
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_2.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_2.hs:13:1:
+ Can't make a derived instance of `Generic1 Term':
+ Int must be a vanilla data constructor
+ In the stand-alone deriving instance for `Generic1 Term'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_3.hs b/testsuite/tests/generics/GenCannotDoRep1_3.hs
new file mode 100644
index 0000000000..466f5b898e
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_3.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module GenCannotDoRep1_3 where
+
+import GHC.Generics
+
+-- We do not support occurrences of the type variable except as the last
+-- argument
+data B a b = B (a, b)
+
+data T a = T (B a Int) deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_3.stderr b/testsuite/tests/generics/GenCannotDoRep1_3.stderr
new file mode 100644
index 0000000000..7312a95158
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_3.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_3.hs:11:33:
+ Can't make a derived instance of `Generic1 T':
+ Constructor `T' must use the last type parameter only as the last argument of a data type, newtype, or (->)
+ In the data declaration for `T'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_4.hs b/testsuite/tests/generics/GenCannotDoRep1_4.hs
new file mode 100644
index 0000000000..0986c33e38
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_4.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module GenCannotDoRep1_4 where
+
+import GHC.Generics
+
+-- We do not support contravariant occurrences of the type variable
+data T a = T (a -> Int) deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_4.stderr b/testsuite/tests/generics/GenCannotDoRep1_4.stderr
new file mode 100644
index 0000000000..2a8d2a699b
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_4.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_4.hs:8:34:
+ Can't make a derived instance of `Generic1 T':
+ Constructor `T' must use the last type parameter only as the last argument of a data type, newtype, or (->)
+ In the data declaration for `T'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_5.hs b/testsuite/tests/generics/GenCannotDoRep1_5.hs
new file mode 100644
index 0000000000..a34c093e2a
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_5.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module GenCannotDoRep1_5 where
+
+import GHC.Generics
+
+-- We do not support occurrences of the type variable except as the last
+-- argument
+data T a = T (a, Int) deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_5.stderr b/testsuite/tests/generics/GenCannotDoRep1_5.stderr
new file mode 100644
index 0000000000..13d25089a5
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_5.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_5.hs:9:32:
+ Can't make a derived instance of `Generic1 T':
+ Constructor `T' must use the last type parameter only as the last argument of a data type, newtype, or (->)
+ In the data declaration for `T'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_6.hs b/testsuite/tests/generics/GenCannotDoRep1_6.hs
new file mode 100644
index 0000000000..a64629c3fb
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_6.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module GenCannotDoRep1_6 where
+
+import GHC.Generics
+
+-- We do not support occurrences of the type variable except as the last
+-- argument: == (->) ((->) a Int) Int
+data T a = T ((a -> Int) -> Int) deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_6.stderr b/testsuite/tests/generics/GenCannotDoRep1_6.stderr
new file mode 100644
index 0000000000..16b822e1c1
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_6.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_6.hs:9:43:
+ Can't make a derived instance of `Generic1 T':
+ Constructor `T' must use the last type parameter only as the last argument of a data type, newtype, or (->)
+ In the data declaration for `T'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_7.hs b/testsuite/tests/generics/GenCannotDoRep1_7.hs
new file mode 100644
index 0000000000..c97f0611e8
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_7.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE DeriveGeneric #-}
+
+module GenCannotDoRep1_7 where
+
+import GHC.Generics
+
+-- We do not support contravariant occurrences of the type variable
+data B a = B (a -> Int)
+
+-- so this fails because B is not representable
+data T a = T (B a) deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_7.stderr b/testsuite/tests/generics/GenCannotDoRep1_7.stderr
new file mode 100644
index 0000000000..3b6af68fb0
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_7.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_7.hs:11:29:
+ Can't make a derived instance of `Generic1 T':
+ must not apply type constructors that cannot be represented with `Rep1' (such as `B') to arguments that involve the last type parameter
+ In the data declaration for `T'
diff --git a/testsuite/tests/generics/GenCannotDoRep1_8.hs b/testsuite/tests/generics/GenCannotDoRep1_8.hs
new file mode 100644
index 0000000000..da31a6d3c5
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_8.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DeriveGeneric, TypeFamilies #-}
+
+module GenCannotDoRep1_8 where
+
+import GHC.Generics
+
+data B a = B (a -> Int)
+
+type family TF (a :: *) :: *
+
+-- We do not support type families
+data T a = T (TF a) deriving Generic1
diff --git a/testsuite/tests/generics/GenCannotDoRep1_8.stderr b/testsuite/tests/generics/GenCannotDoRep1_8.stderr
new file mode 100644
index 0000000000..c0d6929071
--- /dev/null
+++ b/testsuite/tests/generics/GenCannotDoRep1_8.stderr
@@ -0,0 +1,5 @@
+
+GenCannotDoRep1_8.hs:12:30:
+ Can't make a derived instance of `Generic1 T':
+ Constructor `T' must use the last type parameter only as the last argument of a data type, newtype, or (->)
+ In the data declaration for `T'
diff --git a/testsuite/tests/generics/GenDerivOutput.hs b/testsuite/tests/generics/GenDerivOutput.hs
index 227dad6b6c..86e5098ce3 100644
--- a/testsuite/tests/generics/GenDerivOutput.hs
+++ b/testsuite/tests/generics/GenDerivOutput.hs
@@ -1,8 +1,13 @@
+{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# OPTIONS_GHC -ddump-deriv #-}
module GenDerivOutput where
-import GHC.Generics (Generic)
+import GHC.Generics (Generic, Generic1)
-data List a = Nil | Cons { element :: a, rest :: List a } deriving Generic
+data List a = Nil | Cons { element :: a, rest :: List a }
+ deriving (Generic, Generic1, Functor)
+
+data Rose a = Empty | Rose a (List (Rose a))
+ deriving (Generic, Generic1)
diff --git a/testsuite/tests/generics/GenDerivOutput.stderr b/testsuite/tests/generics/GenDerivOutput.stderr
index b703b47768..954ea5ba5d 100644
--- a/testsuite/tests/generics/GenDerivOutput.stderr
+++ b/testsuite/tests/generics/GenDerivOutput.stderr
@@ -20,6 +20,74 @@ Derived instances:
(GHC.Generics.M1 (GHC.Generics.K1 g2))))))
= GenDerivOutput.Cons g1 g2
+ instance GHC.Generics.Generic1 GenDerivOutput.List where
+ GHC.Generics.from1 GenDerivOutput.Nil
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (GenDerivOutput.Cons g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1 (GHC.Generics.Rec1 g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = GenDerivOutput.Nil
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = GenDerivOutput.Cons
+ (GHC.Generics.unPar1 g1) (GHC.Generics.unRec1 g2)
+
+ instance GHC.Base.Functor GenDerivOutput.List where
+ GHC.Base.fmap f GenDerivOutput.Nil = GenDerivOutput.Nil
+ GHC.Base.fmap f (GenDerivOutput.Cons a1 a2)
+ = GenDerivOutput.Cons (f a1) (GHC.Base.fmap (\ b1 -> f b1) a2)
+
+ instance GHC.Generics.Generic (GenDerivOutput.Rose a) where
+ GHC.Generics.from GenDerivOutput.Empty
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from (GenDerivOutput.Rose g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2)))))
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = GenDerivOutput.Empty
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2))))))
+ = GenDerivOutput.Rose g1 g2
+
+ instance GHC.Generics.Generic1 GenDerivOutput.Rose where
+ GHC.Generics.from1 GenDerivOutput.Empty
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (GenDerivOutput.Rose g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1
+ ((GHC.Base..)
+ GHC.Generics.Comp1 (GHC.Base.fmap GHC.Generics.Rec1) g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = GenDerivOutput.Empty
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = GenDerivOutput.Rose
+ (GHC.Generics.unPar1 g1)
+ ((GHC.Base..)
+ (GHC.Base.fmap GHC.Generics.unRec1) GHC.Generics.unComp1 g2)
+
instance GHC.Generics.Datatype GenDerivOutput.D1List where
GHC.Generics.datatypeName _ = "List"
GHC.Generics.moduleName _ = "GenDerivOutput"
@@ -37,6 +105,16 @@ Derived instances:
instance GHC.Generics.Selector GenDerivOutput.S1_1_1List where
GHC.Generics.selName _ = "rest"
+ instance GHC.Generics.Datatype GenDerivOutput.D1Rose where
+ GHC.Generics.datatypeName _ = "Rose"
+ GHC.Generics.moduleName _ = "GenDerivOutput"
+
+ instance GHC.Generics.Constructor GenDerivOutput.C1_0Rose where
+ GHC.Generics.conName _ = "Empty"
+
+ instance GHC.Generics.Constructor GenDerivOutput.C1_1Rose where
+ GHC.Generics.conName _ = "Rose"
+
Generic representation:
@@ -46,6 +124,11 @@ Generic representation:
GenDerivOutput.C1_1List
GenDerivOutput.S1_1_0List
GenDerivOutput.S1_1_1List
+ GenDerivOutput.D1Rose
+ GenDerivOutput.C1_0Rose
+ GenDerivOutput.C1_1Rose
+ GenDerivOutput.S1_1_0Rose
+ GenDerivOutput.S1_1_1Rose
Representation types:
type GHC.Generics.Rep (GenDerivOutput.List a) = GHC.Generics.D1
@@ -56,9 +139,53 @@ Generic representation:
GenDerivOutput.C1_1List
(GHC.Generics.S1
GenDerivOutput.S1_1_0List
- (GHC.Generics.Par0 a)
+ (GHC.Generics.Rec0 a)
GHC.Generics.:*: GHC.Generics.S1
GenDerivOutput.S1_1_1List
(GHC.Generics.Rec0
(GenDerivOutput.List
a))))
+ type GHC.Generics.Rep1 GenDerivOutput.List = GHC.Generics.D1
+ GenDerivOutput.D1List
+ (GHC.Generics.C1
+ GenDerivOutput.C1_0List GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ GenDerivOutput.C1_1List
+ (GHC.Generics.S1
+ GenDerivOutput.S1_1_0List
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ GenDerivOutput.S1_1_1List
+ (GHC.Generics.Rec1
+ GenDerivOutput.List)))
+ type GHC.Generics.Rep (GenDerivOutput.Rose a) = GHC.Generics.D1
+ GenDerivOutput.D1Rose
+ (GHC.Generics.C1
+ GenDerivOutput.C1_0Rose GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ GenDerivOutput.C1_1Rose
+ (GHC.Generics.S1
+ GHC.Generics.NoSelector
+ (GHC.Generics.Rec0 a)
+ GHC.Generics.:*: GHC.Generics.S1
+ GHC.Generics.NoSelector
+ (GHC.Generics.Rec0
+ (GenDerivOutput.List
+ (GenDerivOutput.Rose
+ a)))))
+ type GHC.Generics.Rep1 GenDerivOutput.Rose = GHC.Generics.D1
+ GenDerivOutput.D1Rose
+ (GHC.Generics.C1
+ GenDerivOutput.C1_0Rose GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ GenDerivOutput.C1_1Rose
+ (GHC.Generics.S1
+ GHC.Generics.NoSelector
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ GHC.Generics.NoSelector
+ (GenDerivOutput.List
+ GHC.Generics.:.: GHC.Generics.Rec1
+ GenDerivOutput.Rose)))
+
+
diff --git a/testsuite/tests/generics/GenDerivOutput1_0.hs b/testsuite/tests/generics/GenDerivOutput1_0.hs
new file mode 100644
index 0000000000..8ce1db56b5
--- /dev/null
+++ b/testsuite/tests/generics/GenDerivOutput1_0.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# OPTIONS_GHC -ddump-deriv #-}
+
+module GenDerivOutput1_0 where
+
+import GHC.Generics (Generic1)
+
+data List a = Nil | Cons { element :: a, rest :: List a } deriving Generic1
diff --git a/testsuite/tests/generics/GenDerivOutput1_0.stderr b/testsuite/tests/generics/GenDerivOutput1_0.stderr
new file mode 100644
index 0000000000..e782b6e186
--- /dev/null
+++ b/testsuite/tests/generics/GenDerivOutput1_0.stderr
@@ -0,0 +1,66 @@
+
+==================== Derived instances ====================
+Derived instances:
+ instance GHC.Generics.Generic1 GenDerivOutput1_0.List where
+ GHC.Generics.from1 GenDerivOutput1_0.Nil
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (GenDerivOutput1_0.Cons g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1 (GHC.Generics.Rec1 g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = GenDerivOutput1_0.Nil
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = GenDerivOutput1_0.Cons
+ (GHC.Generics.unPar1 g1) (GHC.Generics.unRec1 g2)
+
+ instance GHC.Generics.Datatype GenDerivOutput1_0.D1List where
+ GHC.Generics.datatypeName _ = "List"
+ GHC.Generics.moduleName _ = "GenDerivOutput1_0"
+
+ instance GHC.Generics.Constructor GenDerivOutput1_0.C1_0List where
+ GHC.Generics.conName _ = "Nil"
+
+ instance GHC.Generics.Constructor GenDerivOutput1_0.C1_1List where
+ GHC.Generics.conName _ = "Cons"
+ GHC.Generics.conIsRecord _ = GHC.Types.True
+
+ instance GHC.Generics.Selector GenDerivOutput1_0.S1_1_0List where
+ GHC.Generics.selName _ = "element"
+
+ instance GHC.Generics.Selector GenDerivOutput1_0.S1_1_1List where
+ GHC.Generics.selName _ = "rest"
+
+
+Generic representation:
+
+ Generated datatypes for meta-information:
+ GenDerivOutput1_0.D1List
+ GenDerivOutput1_0.C1_0List
+ GenDerivOutput1_0.C1_1List
+ GenDerivOutput1_0.S1_1_0List
+ GenDerivOutput1_0.S1_1_1List
+
+ Representation types:
+ type GHC.Generics.Rep1 GenDerivOutput1_0.List = GHC.Generics.D1
+ GenDerivOutput1_0.D1List
+ (GHC.Generics.C1
+ GenDerivOutput1_0.C1_0List GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ GenDerivOutput1_0.C1_1List
+ (GHC.Generics.S1
+ GenDerivOutput1_0.S1_1_0List
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ GenDerivOutput1_0.S1_1_1List
+ (GHC.Generics.Rec1
+ GenDerivOutput1_0.List)))
+
+
diff --git a/testsuite/tests/generics/GenDerivOutput1_1.hs b/testsuite/tests/generics/GenDerivOutput1_1.hs
new file mode 100644
index 0000000000..bafcccf01f
--- /dev/null
+++ b/testsuite/tests/generics/GenDerivOutput1_1.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# OPTIONS_GHC -ddump-deriv #-}
+
+module CanDoRep1_1 where
+
+import GHC.Generics (Generic, Generic1)
+
+
+-- We should be able to generate both generic representations for these types,
+-- without duplicating the meta ty cons
+data Da a = D0 | D1 { d11a :: a, d12a :: (Da a) }
+ deriving (Generic, Generic1)
+
+data Db a = D0b | D1b { d11b :: a, d12b :: (Db a) }
+ deriving (Generic)
+deriving instance Generic1 Db
+
+data Dc a = D0c | D1c { d11c :: a, d12c :: (Dc a) }
+ deriving (Generic1)
+deriving instance Generic (Dc a)
+
+data Dd a = D0d | D1d { d11d :: a, d12d :: (Dd a) }
+deriving instance Generic (Dd a)
+deriving instance Generic1 Dd
diff --git a/testsuite/tests/generics/GenDerivOutput1_1.stderr b/testsuite/tests/generics/GenDerivOutput1_1.stderr
new file mode 100644
index 0000000000..ff6d2578a2
--- /dev/null
+++ b/testsuite/tests/generics/GenDerivOutput1_1.stderr
@@ -0,0 +1,351 @@
+
+==================== Derived instances ====================
+Derived instances:
+ instance GHC.Generics.Generic1 CanDoRep1_1.Dd where
+ GHC.Generics.from1 CanDoRep1_1.D0d
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (CanDoRep1_1.D1d g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1 (GHC.Generics.Rec1 g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0d
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = CanDoRep1_1.D1d (GHC.Generics.unPar1 g1) (GHC.Generics.unRec1 g2)
+
+ instance GHC.Generics.Generic (CanDoRep1_1.Dd a) where
+ GHC.Generics.from CanDoRep1_1.D0d
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from (CanDoRep1_1.D1d g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2)))))
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0d
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2))))))
+ = CanDoRep1_1.D1d g1 g2
+
+ instance GHC.Generics.Generic (CanDoRep1_1.Dc a) where
+ GHC.Generics.from CanDoRep1_1.D0c
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from (CanDoRep1_1.D1c g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2)))))
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0c
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2))))))
+ = CanDoRep1_1.D1c g1 g2
+
+ instance GHC.Generics.Generic1 CanDoRep1_1.Db where
+ GHC.Generics.from1 CanDoRep1_1.D0b
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (CanDoRep1_1.D1b g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1 (GHC.Generics.Rec1 g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0b
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = CanDoRep1_1.D1b (GHC.Generics.unPar1 g1) (GHC.Generics.unRec1 g2)
+
+ instance GHC.Generics.Generic (CanDoRep1_1.Da a) where
+ GHC.Generics.from CanDoRep1_1.D0
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from (CanDoRep1_1.D1 g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2)))))
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2))))))
+ = CanDoRep1_1.D1 g1 g2
+
+ instance GHC.Generics.Generic1 CanDoRep1_1.Da where
+ GHC.Generics.from1 CanDoRep1_1.D0
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (CanDoRep1_1.D1 g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1 (GHC.Generics.Rec1 g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = CanDoRep1_1.D1 (GHC.Generics.unPar1 g1) (GHC.Generics.unRec1 g2)
+
+ instance GHC.Generics.Generic (CanDoRep1_1.Db a) where
+ GHC.Generics.from CanDoRep1_1.D0b
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from (CanDoRep1_1.D1b g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2)))))
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0b
+ GHC.Generics.to
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 (GHC.Generics.K1 g1))
+ (GHC.Generics.M1 (GHC.Generics.K1 g2))))))
+ = CanDoRep1_1.D1b g1 g2
+
+ instance GHC.Generics.Generic1 CanDoRep1_1.Dc where
+ GHC.Generics.from1 CanDoRep1_1.D0c
+ = GHC.Generics.M1
+ (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1))
+ GHC.Generics.from1 (CanDoRep1_1.D1c g1 g2)
+ = GHC.Generics.M1
+ (GHC.Generics.R1
+ (GHC.Generics.M1
+ ((GHC.Generics.:*:)
+ (GHC.Generics.M1 (GHC.Generics.Par1 g1))
+ (GHC.Generics.M1 (GHC.Generics.Rec1 g2)))))
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.L1 (GHC.Generics.M1 GHC.Generics.U1)))
+ = CanDoRep1_1.D0c
+ GHC.Generics.to1
+ (GHC.Generics.M1 (GHC.Generics.R1 (GHC.Generics.M1 (GHC.Generics.:*: (GHC.Generics.M1 g1)
+ (GHC.Generics.M1 g2)))))
+ = CanDoRep1_1.D1c (GHC.Generics.unPar1 g1) (GHC.Generics.unRec1 g2)
+
+ instance GHC.Generics.Datatype CanDoRep1_1.D1Da where
+ GHC.Generics.datatypeName _ = "Da"
+ GHC.Generics.moduleName _ = "CanDoRep1_1"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_0Da where
+ GHC.Generics.conName _ = "D0"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_1Da where
+ GHC.Generics.conName _ = "D1"
+ GHC.Generics.conIsRecord _ = GHC.Types.True
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_0Da where
+ GHC.Generics.selName _ = "d11a"
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_1Da where
+ GHC.Generics.selName _ = "d12a"
+
+ instance GHC.Generics.Datatype CanDoRep1_1.D1Db where
+ GHC.Generics.datatypeName _ = "Db"
+ GHC.Generics.moduleName _ = "CanDoRep1_1"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_0Db where
+ GHC.Generics.conName _ = "D0b"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_1Db where
+ GHC.Generics.conName _ = "D1b"
+ GHC.Generics.conIsRecord _ = GHC.Types.True
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_0Db where
+ GHC.Generics.selName _ = "d11b"
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_1Db where
+ GHC.Generics.selName _ = "d12b"
+
+ instance GHC.Generics.Datatype CanDoRep1_1.D1Dc where
+ GHC.Generics.datatypeName _ = "Dc"
+ GHC.Generics.moduleName _ = "CanDoRep1_1"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_0Dc where
+ GHC.Generics.conName _ = "D0c"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_1Dc where
+ GHC.Generics.conName _ = "D1c"
+ GHC.Generics.conIsRecord _ = GHC.Types.True
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_0Dc where
+ GHC.Generics.selName _ = "d11c"
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_1Dc where
+ GHC.Generics.selName _ = "d12c"
+
+ instance GHC.Generics.Datatype CanDoRep1_1.D1Dd where
+ GHC.Generics.datatypeName _ = "Dd"
+ GHC.Generics.moduleName _ = "CanDoRep1_1"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_0Dd where
+ GHC.Generics.conName _ = "D0d"
+
+ instance GHC.Generics.Constructor CanDoRep1_1.C1_1Dd where
+ GHC.Generics.conName _ = "D1d"
+ GHC.Generics.conIsRecord _ = GHC.Types.True
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_0Dd where
+ GHC.Generics.selName _ = "d11d"
+
+ instance GHC.Generics.Selector CanDoRep1_1.S1_1_1Dd where
+ GHC.Generics.selName _ = "d12d"
+
+
+Generic representation:
+
+ Generated datatypes for meta-information:
+ CanDoRep1_1.D1Da
+ CanDoRep1_1.C1_0Da
+ CanDoRep1_1.C1_1Da
+ CanDoRep1_1.S1_1_0Da
+ CanDoRep1_1.S1_1_1Da
+ CanDoRep1_1.D1Db
+ CanDoRep1_1.C1_0Db
+ CanDoRep1_1.C1_1Db
+ CanDoRep1_1.S1_1_0Db
+ CanDoRep1_1.S1_1_1Db
+ CanDoRep1_1.D1Dc
+ CanDoRep1_1.C1_0Dc
+ CanDoRep1_1.C1_1Dc
+ CanDoRep1_1.S1_1_0Dc
+ CanDoRep1_1.S1_1_1Dc
+ CanDoRep1_1.D1Dd
+ CanDoRep1_1.C1_0Dd
+ CanDoRep1_1.C1_1Dd
+ CanDoRep1_1.S1_1_0Dd
+ CanDoRep1_1.S1_1_1Dd
+
+ Representation types:
+ type GHC.Generics.Rep1 CanDoRep1_1.Dd = GHC.Generics.D1
+ CanDoRep1_1.D1Dd
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Dd GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Dd
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Dd
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Dd
+ (GHC.Generics.Rec1
+ CanDoRep1_1.Dd)))
+ type GHC.Generics.Rep (CanDoRep1_1.Dd a) = GHC.Generics.D1
+ CanDoRep1_1.D1Dd
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Dd GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Dd
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Dd
+ (GHC.Generics.Rec0 a)
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Dd
+ (GHC.Generics.Rec0
+ (CanDoRep1_1.Dd
+ a))))
+ type GHC.Generics.Rep (CanDoRep1_1.Dc a) = GHC.Generics.D1
+ CanDoRep1_1.D1Dc
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Dc GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Dc
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Dc
+ (GHC.Generics.Rec0 a)
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Dc
+ (GHC.Generics.Rec0
+ (CanDoRep1_1.Dc
+ a))))
+ type GHC.Generics.Rep1 CanDoRep1_1.Db = GHC.Generics.D1
+ CanDoRep1_1.D1Db
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Db GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Db
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Db
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Db
+ (GHC.Generics.Rec1
+ CanDoRep1_1.Db)))
+ type GHC.Generics.Rep (CanDoRep1_1.Da a) = GHC.Generics.D1
+ CanDoRep1_1.D1Da
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Da GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Da
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Da
+ (GHC.Generics.Rec0 a)
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Da
+ (GHC.Generics.Rec0
+ (CanDoRep1_1.Da
+ a))))
+ type GHC.Generics.Rep1 CanDoRep1_1.Da = GHC.Generics.D1
+ CanDoRep1_1.D1Da
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Da GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Da
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Da
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Da
+ (GHC.Generics.Rec1
+ CanDoRep1_1.Da)))
+ type GHC.Generics.Rep (CanDoRep1_1.Db a) = GHC.Generics.D1
+ CanDoRep1_1.D1Db
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Db GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Db
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Db
+ (GHC.Generics.Rec0 a)
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Db
+ (GHC.Generics.Rec0
+ (CanDoRep1_1.Db
+ a))))
+ type GHC.Generics.Rep1 CanDoRep1_1.Dc = GHC.Generics.D1
+ CanDoRep1_1.D1Dc
+ (GHC.Generics.C1 CanDoRep1_1.C1_0Dc GHC.Generics.U1
+ GHC.Generics.:+: GHC.Generics.C1
+ CanDoRep1_1.C1_1Dc
+ (GHC.Generics.S1
+ CanDoRep1_1.S1_1_0Dc
+ GHC.Generics.Par1
+ GHC.Generics.:*: GHC.Generics.S1
+ CanDoRep1_1.S1_1_1Dc
+ (GHC.Generics.Rec1
+ CanDoRep1_1.Dc)))
+
+
diff --git a/testsuite/tests/generics/GenShouldFail1_0.hs b/testsuite/tests/generics/GenShouldFail1_0.hs
new file mode 100644
index 0000000000..15f059d65d
--- /dev/null
+++ b/testsuite/tests/generics/GenShouldFail1_0.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE StandaloneDeriving #-}
+
+module ShouldFail1_0 where
+
+import GHC.Generics (Generic1)
+
+data X a = X
+
+deriving instance Generic1 X
+
+-- Should fail (no XDeriveGeneric)
diff --git a/testsuite/tests/generics/GenShouldFail1_0.stderr b/testsuite/tests/generics/GenShouldFail1_0.stderr
new file mode 100644
index 0000000000..9b7ba3ef07
--- /dev/null
+++ b/testsuite/tests/generics/GenShouldFail1_0.stderr
@@ -0,0 +1,5 @@
+
+GenShouldFail1_0.hs:9:1:
+ Can't make a derived instance of `Generic1 X':
+ You need -XDeriveGeneric to derive an instance for this class
+ In the stand-alone deriving instance for `Generic1 X'
diff --git a/testsuite/tests/generics/all.T b/testsuite/tests/generics/all.T
index 2382d8b42f..1541a4725c 100644
--- a/testsuite/tests/generics/all.T
+++ b/testsuite/tests/generics/all.T
@@ -1,6 +1,7 @@
setTestOpts(only_compiler_types(['ghc']))
test('GenCanDoRep0', normal, compile, [''])
+test('GenCanDoRep1', normal, compile, [''])
test('GenDerivOutput', normal, compile, ['-dsuppress-uniques'])
test('GenShouldFail0', normal, compile_fail, [''])
@@ -8,3 +9,18 @@ test('GenCannotDoRep0', normal, compile_fail, [''])
test('GenCannotDoRep1', normal, compile_fail, [''])
test('GenCannotDoRep2', normal, compile_fail, [''])
test('T5884', normal, compile, [''])
+
+test('GenCanDoRep1_0', normal, compile, [''])
+test('GenDerivOutput1_0', normal, compile, ['-dsuppress-uniques'])
+test('GenDerivOutput1_1', normal, compile, ['-dsuppress-uniques'])
+
+test('GenShouldFail1_0', normal, compile_fail, [''])
+test('GenCannotDoRep1_0', normal, compile_fail, [''])
+test('GenCannotDoRep1_1', normal, compile_fail, [''])
+test('GenCannotDoRep1_2', normal, compile_fail, [''])
+test('GenCannotDoRep1_3', normal, compile_fail, [''])
+test('GenCannotDoRep1_4', normal, compile_fail, [''])
+test('GenCannotDoRep1_5', normal, compile_fail, [''])
+test('GenCannotDoRep1_6', normal, compile_fail, [''])
+test('GenCannotDoRep1_7', normal, compile_fail, [''])
+test('GenCannotDoRep1_8', normal, compile_fail, ['']) \ No newline at end of file
diff --git a/testsuite/tests/ghci.debugger/scripts/break006.stderr b/testsuite/tests/ghci.debugger/scripts/break006.stderr
index dfe51addd4..ae2585f00f 100644
--- a/testsuite/tests/ghci.debugger/scripts/break006.stderr
+++ b/testsuite/tests/ghci.debugger/scripts/break006.stderr
@@ -8,7 +8,7 @@
instance Show Float -- Defined in `GHC.Float'
instance (Integral a, Show a) => Show (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
- ...plus 26 others
+ ...plus 23 others
In a stmt of an interactive GHCi command: print it
<interactive>:8:1:
@@ -20,5 +20,5 @@
instance Show Float -- Defined in `GHC.Float'
instance (Integral a, Show a) => Show (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
- ...plus 26 others
+ ...plus 23 others
In a stmt of an interactive GHCi command: print it
diff --git a/testsuite/tests/ghci.debugger/scripts/print019.stderr b/testsuite/tests/ghci.debugger/scripts/print019.stderr
index 7b7b1309ad..f23daf2191 100644
--- a/testsuite/tests/ghci.debugger/scripts/print019.stderr
+++ b/testsuite/tests/ghci.debugger/scripts/print019.stderr
@@ -7,5 +7,5 @@
instance Show a => Show (List1 a) -- Defined at ../Test.hs:11:12
instance Show MyInt -- Defined at ../Test.hs:14:16
instance Show a => Show (MkT a) -- Defined at ../Test.hs:17:13
- ...plus 34 others
+ ...plus 31 others
In a stmt of an interactive GHCi command: print it
diff --git a/testsuite/tests/typecheck/should_fail/T5095.stderr b/testsuite/tests/typecheck/should_fail/T5095.stderr
index 1cfcfea306..6ef994fdc6 100644
--- a/testsuite/tests/typecheck/should_fail/T5095.stderr
+++ b/testsuite/tests/typecheck/should_fail/T5095.stderr
@@ -48,12 +48,9 @@ T5095.hs:9:11:
Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) =>
Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
-- Defined in `GHC.Classes'
- instance Eq GHC.Generics.Arity -- Defined in `GHC.Classes'
- instance Eq GHC.Generics.Associativity -- Defined in `GHC.Classes'
instance Eq Bool -- Defined in `GHC.Classes'
instance Eq Char -- Defined in `GHC.Classes'
instance Eq Double -- Defined in `GHC.Classes'
- instance Eq GHC.Generics.Fixity -- Defined in `GHC.Classes'
instance Eq Float -- Defined in `GHC.Classes'
instance Eq Int -- Defined in `GHC.Classes'
instance Eq Ordering -- Defined in `GHC.Classes'
diff --git a/testsuite/tests/typecheck/should_fail/tcfail072.stderr b/testsuite/tests/typecheck/should_fail/tcfail072.stderr
index aec686716e..087d12b400 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail072.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail072.stderr
@@ -12,6 +12,6 @@ tcfail072.hs:23:13:
-- Defined in `GHC.Real'
instance Ord () -- Defined in `GHC.Classes'
instance (Ord a, Ord b) => Ord (a, b) -- Defined in `GHC.Classes'
- ...plus 25 others
+ ...plus 22 others
In the expression: g A
In an equation for `g': g (B _ _) = g A
diff --git a/testsuite/tests/typecheck/should_fail/tcfail133.stderr b/testsuite/tests/typecheck/should_fail/tcfail133.stderr
index 042a87a082..08c9b9747d 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail133.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail133.stderr
@@ -11,7 +11,7 @@ tcfail133.hs:68:7:
instance Show One -- Defined at tcfail133.hs:9:28
instance (Show a, Show b, Number a, Digit b) => Show (a :@ b)
-- Defined at tcfail133.hs:11:54
- ...plus 29 others
+ ...plus 26 others
In the expression: show
In the expression: show $ add (One :@ Zero) (One :@ One)
In an equation for `foo':