Add tests for deriving Generic1
authorJose Pedro Magalhaes <jpm@cs.ox.ac.uk>
Thu, 21 Jun 2012 11:13:33 +0000 (12:13 +0100)
committerJose Pedro Magalhaes <jpm@cs.ox.ac.uk>
Thu, 21 Jun 2012 11:13:49 +0000 (12:13 +0100)
Most of these tests were written by Nicolas Frisby.

46 files changed:
testsuite/tests/generics/GFunctor/GFunctor.hs [new file with mode: 0644]
testsuite/tests/generics/GFunctor/GFunctor1.stdout [new file with mode: 0644]
testsuite/tests/generics/GFunctor/Main.hs [new file with mode: 0644]
testsuite/tests/generics/GFunctor/Makefile [new file with mode: 0644]
testsuite/tests/generics/GFunctor/test.T [new file with mode: 0644]
testsuite/tests/generics/GMap/GMap.hs [new file with mode: 0644]
testsuite/tests/generics/GMap/GMap1.stdout [new file with mode: 0644]
testsuite/tests/generics/GMap/Main.hs [new file with mode: 0644]
testsuite/tests/generics/GMap/Makefile [new file with mode: 0644]
testsuite/tests/generics/GMap/test.T [new file with mode: 0644]
testsuite/tests/generics/GenCanDoRep1.hs [new file with mode: 0644]
testsuite/tests/generics/GenCanDoRep1_0.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep0.hs
testsuite/tests/generics/GenCannotDoRep0.stderr
testsuite/tests/generics/GenCannotDoRep1_0.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_0.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_1.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_1.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_2.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_2.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_3.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_3.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_4.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_4.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_5.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_5.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_6.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_6.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_7.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_7.stderr [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_8.hs [new file with mode: 0644]
testsuite/tests/generics/GenCannotDoRep1_8.stderr [new file with mode: 0644]
testsuite/tests/generics/GenDerivOutput.hs
testsuite/tests/generics/GenDerivOutput.stderr
testsuite/tests/generics/GenDerivOutput1_0.hs [new file with mode: 0644]
testsuite/tests/generics/GenDerivOutput1_0.stderr [new file with mode: 0644]
testsuite/tests/generics/GenDerivOutput1_1.hs [new file with mode: 0644]
testsuite/tests/generics/GenDerivOutput1_1.stderr [new file with mode: 0644]
testsuite/tests/generics/GenShouldFail1_0.hs [new file with mode: 0644]
testsuite/tests/generics/GenShouldFail1_0.stderr [new file with mode: 0644]
testsuite/tests/generics/all.T
testsuite/tests/ghci.debugger/scripts/break006.stderr
testsuite/tests/ghci.debugger/scripts/print019.stderr
testsuite/tests/typecheck/should_fail/T5095.stderr
testsuite/tests/typecheck/should_fail/tcfail072.stderr
testsuite/tests/typecheck/should_fail/tcfail133.stderr

diff --git a/testsuite/tests/generics/GFunctor/GFunctor.hs b/testsuite/tests/generics/GFunctor/GFunctor.hs
new file mode 100644 (file)
index 0000000..0044339
--- /dev/null
@@ -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 (file)
index 0000000..966a020
--- /dev/null
@@ -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 (file)
index 0000000..7d0a3df
--- /dev/null
@@ -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 (file)
index 0000000..9101fbd
--- /dev/null
@@ -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 (file)
index 0000000..7018d8f
--- /dev/null
@@ -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 (file)
index 0000000..e7d57de
--- /dev/null
@@ -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 (file)
index 0000000..f24d682
--- /dev/null
@@ -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 (file)
index 0000000..0d44621
--- /dev/null
@@ -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 (file)
index 0000000..9101fbd
--- /dev/null
@@ -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 (file)
index 0000000..e83a2d8
--- /dev/null
@@ -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 (file)
index 0000000..16ca81d
--- /dev/null
@@ -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 (file)
index 0000000..db557d8
--- /dev/null
@@ -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)
index 5b4f93f..21beb8a 100644 (file)
@@ -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 () ())
index a12602d..e222819 100644 (file)
@@ -1,5 +1,23 @@
-\r
-GenCannotDoRep0.hs:9:45:\r
-    Can't make a derived instance of `Generic Dynamic':\r
-      Dynamic must be a vanilla data constructor\r
-    In the data declaration for `Dynamic'\r
+
+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 (file)
index 0000000..3e3c409
--- /dev/null
@@ -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 (file)
index 0000000..2e602af
--- /dev/null
@@ -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 (file)
index 0000000..9ac8fc6
--- /dev/null
@@ -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 (file)
index 0000000..df9f518
--- /dev/null
@@ -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 (file)
index 0000000..cdbbed5
--- /dev/null
@@ -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 (file)
index 0000000..ffda5ff
--- /dev/null
@@ -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 (file)
index 0000000..466f5b8
--- /dev/null
@@ -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 (file)
index 0000000..7312a95
--- /dev/null
@@ -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 (file)
index 0000000..0986c33
--- /dev/null
@@ -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 (file)
index 0000000..2a8d2a6
--- /dev/null
@@ -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 (file)
index 0000000..a34c093
--- /dev/null
@@ -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 (file)
index 0000000..13d2508
--- /dev/null
@@ -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 (file)
index 0000000..a64629c
--- /dev/null
@@ -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 (file)
index 0000000..16b822e
--- /dev/null
@@ -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 (file)
index 0000000..c97f061
--- /dev/null
@@ -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 (file)
index 0000000..3b6af68
--- /dev/null
@@ -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 (file)
index 0000000..da31a6d
--- /dev/null
@@ -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 (file)
index 0000000..c0d6929
--- /dev/null
@@ -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'
index 227dad6..86e5098 100644 (file)
@@ -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)
index b703b47..954ea5b 100644 (file)
@@ -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 (file)
index 0000000..8ce1db5
--- /dev/null
@@ -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 (file)
index 0000000..e782b6e
--- /dev/null
@@ -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 (file)
index 0000000..bafcccf
--- /dev/null
@@ -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 (file)
index 0000000..ff6d257
--- /dev/null
@@ -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 (file)
index 0000000..15f059d
--- /dev/null
@@ -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 (file)
index 0000000..9b7ba3e
--- /dev/null
@@ -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'
index 2382d8b..1541a47 100644 (file)
@@ -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
index dfe51ad..ae2585f 100644 (file)
@@ -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
index 7b7b130..f23daf2 100644 (file)
@@ -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
index 1cfcfea..6ef994f 100644 (file)
@@ -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'
index aec6867..087d12b 100644 (file)
@@ -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
index 042a87a..08c9b97 100644 (file)
@@ -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':