summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_compile
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/deriving/should_compile')
-rw-r--r--testsuite/tests/deriving/should_compile/Makefile3
-rw-r--r--testsuite/tests/deriving/should_compile/T2378.hs10
-rw-r--r--testsuite/tests/deriving/should_compile/T2856.hs28
-rw-r--r--testsuite/tests/deriving/should_compile/T3012.hs10
-rw-r--r--testsuite/tests/deriving/should_compile/T3057.hs6
-rw-r--r--testsuite/tests/deriving/should_compile/T3965.hs23
-rw-r--r--testsuite/tests/deriving/should_compile/T4220.hs7
-rw-r--r--testsuite/tests/deriving/should_compile/T4302.hs18
-rw-r--r--testsuite/tests/deriving/should_compile/T4325.hs7
-rw-r--r--testsuite/tests/deriving/should_compile/T4325.stderr3
-rw-r--r--testsuite/tests/deriving/should_compile/T4816.hs10
-rw-r--r--testsuite/tests/deriving/should_compile/T4966.hs44
-rw-r--r--testsuite/tests/deriving/should_compile/T4966.stderr3
-rw-r--r--testsuite/tests/deriving/should_compile/all.T32
-rw-r--r--testsuite/tests/deriving/should_compile/deriving-1935.hs22
-rw-r--r--testsuite/tests/deriving/should_compile/drv-foldable-traversable1.hs33
-rw-r--r--testsuite/tests/deriving/should_compile/drv-foldable-traversable1.stderr3
-rw-r--r--testsuite/tests/deriving/should_compile/drv-functor1.hs65
-rw-r--r--testsuite/tests/deriving/should_compile/drv-functor1.stderr3
-rw-r--r--testsuite/tests/deriving/should_compile/drv-functor2.hs9
-rw-r--r--testsuite/tests/deriving/should_compile/drv001.hs21
-rw-r--r--testsuite/tests/deriving/should_compile/drv001.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv002.hs14
-rw-r--r--testsuite/tests/deriving/should_compile/drv002.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv003.hs17
-rw-r--r--testsuite/tests/deriving/should_compile/drv003.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv004.hs9
-rw-r--r--testsuite/tests/deriving/should_compile/drv004.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv005.hs6
-rw-r--r--testsuite/tests/deriving/should_compile/drv005.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv006.hs9
-rw-r--r--testsuite/tests/deriving/should_compile/drv006.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv007.hs6
-rw-r--r--testsuite/tests/deriving/should_compile/drv007.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv008.hs7
-rw-r--r--testsuite/tests/deriving/should_compile/drv008.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv009.hs6
-rw-r--r--testsuite/tests/deriving/should_compile/drv009.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv010.hs4
-rw-r--r--testsuite/tests/deriving/should_compile/drv010.stderr0
-rw-r--r--testsuite/tests/deriving/should_compile/drv011.hs6
-rw-r--r--testsuite/tests/deriving/should_compile/drv012.hs10
-rw-r--r--testsuite/tests/deriving/should_compile/drv013.hs11
-rw-r--r--testsuite/tests/deriving/should_compile/drv014.hs11
-rw-r--r--testsuite/tests/deriving/should_compile/drv015.hs14
-rw-r--r--testsuite/tests/deriving/should_compile/drv020.hs34
-rw-r--r--testsuite/tests/deriving/should_compile/drv021.hs16
47 files changed, 540 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_compile/Makefile b/testsuite/tests/deriving/should_compile/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/deriving/should_compile/T2378.hs b/testsuite/tests/deriving/should_compile/T2378.hs
new file mode 100644
index 0000000000..e3118cb863
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T2378.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}
+module Foo( T ) where
+
+-- Trac 2378
+
+import Data.Data
+
+newtype T f = MkT Int
+
+deriving instance Typeable1 T
diff --git a/testsuite/tests/deriving/should_compile/T2856.hs b/testsuite/tests/deriving/should_compile/T2856.hs
new file mode 100644
index 0000000000..c8f81a00bc
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T2856.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving, StandaloneDeriving, FlexibleInstances #-}
+
+-- Test Trac #2856
+
+module T2856 where
+
+import Data.Ratio
+
+----------------------
+class C a where
+ data D a
+
+instance C Bool where
+ newtype D Bool = DInt Int deriving (Eq, Show, Num)
+
+instance C a => C [a] where
+ newtype D [a] = DList (Ratio a) deriving (Eq, Show, Num)
+
+----------------------
+data family W a
+newtype instance W Bool = WInt Int deriving( Eq, Show )
+newtype instance W [a] = WList (Ratio a) deriving( Eq, Show )
+
+deriving instance Num (W Bool)
+deriving instance (Integral a, Num a) => Num (W [a])
+ -- Integral needed because superclass Eq needs it,
+ -- because of the stupid context on Ratio
+
diff --git a/testsuite/tests/deriving/should_compile/T3012.hs b/testsuite/tests/deriving/should_compile/T3012.hs
new file mode 100644
index 0000000000..44b1d64a9c
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T3012.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE GADTs, StandaloneDeriving #-}
+
+module T3012 where
+
+data T a where
+ Foo :: T Int
+ Bar :: T Bool
+
+deriving instance Show (T a)
+
diff --git a/testsuite/tests/deriving/should_compile/T3057.hs b/testsuite/tests/deriving/should_compile/T3057.hs
new file mode 100644
index 0000000000..0e9aef7814
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T3057.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE StandaloneDeriving, DeriveFunctor #-}
+module T3057 where
+
+deriving instance Functor (Either a)
+
+
diff --git a/testsuite/tests/deriving/should_compile/T3965.hs b/testsuite/tests/deriving/should_compile/T3965.hs
new file mode 100644
index 0000000000..2ccaaadfdf
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T3965.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, StandaloneDeriving, TypeOperators, UndecidableInstances #-}
+module T3965 where
+
+import Data.Data
+
+data T f e = Inl (f e) deriving (Data, Eq)
+
+instance (Typeable1 f) => Typeable1 (T f) where
+ typeOf1 _ = error "urk"
+
+newtype Expr f = In (f (Expr f))
+instance Typeable1 f => Typeable (Expr f) where
+ typeOf _ = error "urk"
+
+deriving instance (Typeable1 a, Data (a (Expr a))) => Data (Expr a)
+
+data Var e = Var String deriving (Data, Eq, Typeable)
+
+data Domain e g = Domain
+ (Expr (T Var))
+ deriving (Data, Typeable)
+
+
diff --git a/testsuite/tests/deriving/should_compile/T4220.hs b/testsuite/tests/deriving/should_compile/T4220.hs
new file mode 100644
index 0000000000..0b2ba28caa
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4220.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE EmptyDataDecls, DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
+module T4220 where
+
+import Data.Foldable
+import Data.Traversable
+
+data Void a deriving (Functor, Foldable, Traversable)
diff --git a/testsuite/tests/deriving/should_compile/T4302.hs b/testsuite/tests/deriving/should_compile/T4302.hs
new file mode 100644
index 0000000000..50369632f9
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4302.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable, DeriveFunctor, DeriveFoldable, DeriveTraversable, EmptyDataDecls #-}
+module T4302 where
+
+import Data.Ix
+import Data.Typeable
+import Data.Data
+import Data.Foldable
+import Data.Traversable
+
+data Test a
+
+deriving instance Eq (Test a)
+deriving instance Ord (Test a)
+deriving instance Typeable1 Test
+deriving instance Data a => Data (Test a)
+deriving instance Functor Test
+deriving instance Foldable Test
+deriving instance Traversable Test
diff --git a/testsuite/tests/deriving/should_compile/T4325.hs b/testsuite/tests/deriving/should_compile/T4325.hs
new file mode 100644
index 0000000000..68ab81744b
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4325.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE DatatypeContexts #-}
+
+module T4325 where
+
+data Ord a => Heap a b = Empty | Node a b [Heap a b]
+ deriving Eq
+
diff --git a/testsuite/tests/deriving/should_compile/T4325.stderr b/testsuite/tests/deriving/should_compile/T4325.stderr
new file mode 100644
index 0000000000..90ef1de92d
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4325.stderr
@@ -0,0 +1,3 @@
+
+T4325.hs:1:14:
+ Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
diff --git a/testsuite/tests/deriving/should_compile/T4816.hs b/testsuite/tests/deriving/should_compile/T4816.hs
new file mode 100644
index 0000000000..0e81e39521
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4816.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE DeriveFunctor #-}
+
+module T4816 where
+
+data Silly a = Sillly a
+
+data Baz o = Baz {
+ foo :: o,
+ bar :: Silly ()
+ } deriving (Functor)
diff --git a/testsuite/tests/deriving/should_compile/T4966.hs b/testsuite/tests/deriving/should_compile/T4966.hs
new file mode 100644
index 0000000000..d7328c6ef6
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4966.hs
@@ -0,0 +1,44 @@
+{-# LANGUAGE DatatypeContexts #-}
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# LANGUAGE OverlappingInstances #-}
+
+module HTk.Toolkit.TreeList (getObjectFromTreeList) where
+
+class Eq c => CItem c
+
+-- A bizarre instance decl!
+-- People who use instance decls like this are asking for trouble
+instance GUIObject w => Eq w where
+ w1 == w2 = toGUIObject w1 == toGUIObject w2
+
+data StateEntry a
+ = StateEntry (TreeListObject a) a -- Comment this 'a' out and it type checks
+ deriving Eq
+
+-- The delicate point about this test is that we want to
+-- infer a derived instance decl like this:
+-- instance (CItem a, Eq a) => Eq (StateEntry a)
+-- But note the instance decl for (Eq w) for any w!
+-- There's a danger than we'll use that instance decl
+-- to get the derived instance
+-- instance (CItem a, GUIObject a) => Eq (StateEntry a)
+-- And then that doesn't work subsequently
+
+getObjectFromTreeList :: CItem a => StateEntry a -> Bool
+getObjectFromTreeList state = state == state
+
+data CItem a => TreeListObject a
+
+instance CItem a => Eq (TreeListObject a)
+
+class GUIObject w where
+ toGUIObject :: w -> GUIOBJECT
+
+
+data GUIOBJECT
+
+instance Eq GUIOBJECT where
+ (==) = undefined
+ (/=) = undefined
diff --git a/testsuite/tests/deriving/should_compile/T4966.stderr b/testsuite/tests/deriving/should_compile/T4966.stderr
new file mode 100644
index 0000000000..b8059925bb
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T4966.stderr
@@ -0,0 +1,3 @@
+
+T4966.hs:1:14:
+ Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
new file mode 100644
index 0000000000..22353ab2ea
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -0,0 +1,32 @@
+test('drv001', normal, compile, [''])
+test('drv002', normal, compile, [''])
+test('drv003', normal, compile, [''])
+test('drv004', normal, compile, [''])
+test('drv005', normal, compile, [''])
+test('drv006', normal, compile, [''])
+test('drv007', normal, compile, [''])
+test('drv008', normal, compile, [''])
+test('drv009', normal, compile, [''])
+test('drv010', normal, compile, [''])
+test('drv011', normal, compile, [''])
+test('drv012', normal, compile, [''])
+test('drv013', normal, compile, [''])
+test('drv014', normal, compile, [''])
+test('drv015', normal, compile, [''])
+test('drv020', normal, compile, [''])
+test('drv021', normal, compile, [''])
+test('deriving-1935', normal, compile, [''])
+test('T2378', normal, compile, [''])
+test('T2856', normal, compile, [''])
+test('T3057', normal, compile, [''])
+test('T3012', normal, compile, [''])
+test('T3965', normal, compile, [''])
+test('T4220', normal, compile, [''])
+test('T4302', normal, compile, [''])
+test('T4325', normal, compile, [''])
+test('T4816', normal, compile, [''])
+test('T4966', normal, compile, [''])
+
+test('drv-functor1', normal, compile, [''])
+test('drv-functor2', normal, compile, [''])
+test('drv-foldable-traversable1', normal, compile, [''])
diff --git a/testsuite/tests/deriving/should_compile/deriving-1935.hs b/testsuite/tests/deriving/should_compile/deriving-1935.hs
new file mode 100644
index 0000000000..5b3bca0c77
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/deriving-1935.hs
@@ -0,0 +1,22 @@
+{-# OPTIONS_GHC -XDeriveDataTypeable #-}
+
+-- Trac #1935
+-- See Note [Superclasses of derived instance] in TcDeriv
+
+module Foo where
+
+ import Data.Data
+
+ data Foo a = Foo
+ deriving (Data, Typeable)
+
+ data T a = MkT (S a) deriving( Ord )
+
+ instance Num a => Eq (T a)
+
+ data S a = S
+ instance Eq (S a)
+ instance Ord (S a)
+
+
+ \ No newline at end of file
diff --git a/testsuite/tests/deriving/should_compile/drv-foldable-traversable1.hs b/testsuite/tests/deriving/should_compile/drv-foldable-traversable1.hs
new file mode 100644
index 0000000000..712f14a3b5
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv-foldable-traversable1.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE FlexibleContexts, DatatypeContexts #-}
+
+module ShouldCompile where
+
+import Data.Foldable
+import Data.Traversable
+
+data Trivial a = Trivial
+ deriving (Functor,Foldable,Traversable)
+
+-- lots of different things
+data Strange a b c
+ = T1 a b c
+ | T2 c c c
+ | T3 [a] [b] [c] -- lists
+ | T4 [[a]] [[b]] [[c]] -- nested lists
+ | T5 (c,(b,b),(c,c)) -- tuples
+ | T6 ([c],Strange a b c) -- tycons
+ deriving (Functor,Foldable,Traversable)
+
+data NotPrimitivelyRecursive a
+ = S1 (NotPrimitivelyRecursive (a,a))
+ | S2 a
+ deriving (Functor,Foldable,Traversable)
+
+data Eq a => StupidConstraint a b = Stupid a b
+ deriving (Functor,Foldable,Traversable)
+
+-- requires Foldable/Traversable constraint on f and g
+data Compose f g a = Compose (f (g a))
+ deriving (Functor,Foldable,Traversable)
diff --git a/testsuite/tests/deriving/should_compile/drv-foldable-traversable1.stderr b/testsuite/tests/deriving/should_compile/drv-foldable-traversable1.stderr
new file mode 100644
index 0000000000..ceae10cabd
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv-foldable-traversable1.stderr
@@ -0,0 +1,3 @@
+
+drv-foldable-traversable1.hs:3:32:
+ Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
diff --git a/testsuite/tests/deriving/should_compile/drv-functor1.hs b/testsuite/tests/deriving/should_compile/drv-functor1.hs
new file mode 100644
index 0000000000..8249858cae
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv-functor1.hs
@@ -0,0 +1,65 @@
+{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE DatatypeContexts #-}
+
+module ShouldCompile where
+
+data Trivial a = Trivial
+ deriving (Functor)
+
+data Fun a = Fun (Int -> a)
+ deriving (Functor)
+
+-- lots of different things
+data Strange a b c
+ = T1 a b c
+ | T2 [a] [b] [c] -- lists
+ | T3 [[a]] [[b]] [[c]] -- nested lists
+ | T4 (c,(b,b),(c,c)) -- tuples
+ | T5 ([c],Strange a b c) -- tycons
+ | T6 (Int -> c) -- function types
+ | T7 (a -> (c,a)) -- functions and tuples
+ | T8 ((c -> a) -> a) -- continuation
+ deriving (Functor)
+
+data NotPrimitivelyRecursive a
+ = S1 (NotPrimitivelyRecursive (a,a))
+ | S2 a
+ deriving (Functor,Eq)
+
+data Eq a => StupidConstraint a b = Stupid a b
+ deriving (Functor)
+
+-- requires Functor constraint on f and g
+data Compose f g a = Compose (f (g a))
+ deriving (Functor)
+
+-- We can't derive Functor for the following type.
+-- it needs both (Functor (f Int)) and (Functor (f Bool))
+-- i.e.:
+-- instance (Functor (f Bool), Functor (f Int)) => Functor (ComplexConstraint f)
+-- This requires FlexibleContexts and UndecidableInstances
+data ComplexConstraint f a = ComplexContraint (f Int (f Bool a,a))
+-- deriving (Functor)
+
+data Universal a
+ = Universal (forall b. (b,[a]))
+ | Universal2 (forall f. Functor f => (f a))
+ | Universal3 (forall a. a -> Int) -- reuse a
+ | NotReallyUniversal (forall b. a)
+ deriving (Functor)
+
+-- Ghc doesn't allow deriving for non-Haskell98 data constructors
+data Existential b
+ = forall a. ExistentialList [a]
+ | forall f. Functor f => ExistentialFunctor (f b)
+ | forall b. SneakyUseSameName (b -> Bool)
+ -- deriving (Functor)
+
+-- Don't get confused by synonyms
+type IntFun a = Int -> a
+data IntFunD a = IntFunD (IntFun a)
+ deriving (Functor)
+
diff --git a/testsuite/tests/deriving/should_compile/drv-functor1.stderr b/testsuite/tests/deriving/should_compile/drv-functor1.stderr
new file mode 100644
index 0000000000..a531dc56ef
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv-functor1.stderr
@@ -0,0 +1,3 @@
+
+drv-functor1.hs:5:14:
+ Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
diff --git a/testsuite/tests/deriving/should_compile/drv-functor2.hs b/testsuite/tests/deriving/should_compile/drv-functor2.hs
new file mode 100644
index 0000000000..d070feb06d
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv-functor2.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
+module ShouldCompile where
+
+-- Deriving Functor should still work with GeneralizedNewtypeDeriving instead of DeriveFunctor
+
+newtype List a = List [a]
+ deriving (Functor)
+
diff --git a/testsuite/tests/deriving/should_compile/drv001.hs b/testsuite/tests/deriving/should_compile/drv001.hs
new file mode 100644
index 0000000000..694af6a50f
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv001.hs
@@ -0,0 +1,21 @@
+-- !!! canonical weird example for "deriving"
+module ShouldSucceed where
+
+data X a b
+ = C1 (T a)
+ | C2 (Y b)
+ | C3 (X b a)
+ deriving (Read, Show)
+
+data Y b
+ = D1
+ | D2 (X Int b)
+ deriving (Read, Show)
+
+data T a
+ = E1
+
+instance Eq a => Show (T a) where
+ showsPrec = error "show"
+instance Eq a => Read (T a) where
+ readsPrec = error "read"
diff --git a/testsuite/tests/deriving/should_compile/drv001.stderr b/testsuite/tests/deriving/should_compile/drv001.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv001.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv002.hs b/testsuite/tests/deriving/should_compile/drv002.hs
new file mode 100644
index 0000000000..15eb2d9ecc
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv002.hs
@@ -0,0 +1,14 @@
+module ShouldSucceed where
+
+data Z a b
+ = C1 (T a)
+ | C2 (Z [a] [b])
+ deriving (Show, Read)
+
+data T a
+ = E1
+
+instance Eq a => Show (T a) where
+ showsPrec = error "show"
+instance Eq a => Read (T a) where
+ readsPrec = error "read"
diff --git a/testsuite/tests/deriving/should_compile/drv002.stderr b/testsuite/tests/deriving/should_compile/drv002.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv002.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv003.hs b/testsuite/tests/deriving/should_compile/drv003.hs
new file mode 100644
index 0000000000..0b8149ce8a
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv003.hs
@@ -0,0 +1,17 @@
+-- !!! This is the example given in TcDeriv
+--
+module ShouldSucceed where
+
+data T a b
+ = C1 (Foo a) (Bar b)
+ | C2 Int (T b a)
+ | C3 (T a a)
+ deriving Eq
+
+data Foo a = MkFoo Double a deriving ()
+instance (Eq a) => Eq (Foo a)
+
+data Bar a = MkBar Int Int deriving ()
+instance (Ping b) => Eq (Bar b)
+
+class Ping a
diff --git a/testsuite/tests/deriving/should_compile/drv003.stderr b/testsuite/tests/deriving/should_compile/drv003.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv003.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv004.hs b/testsuite/tests/deriving/should_compile/drv004.hs
new file mode 100644
index 0000000000..324a7f81d4
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv004.hs
@@ -0,0 +1,9 @@
+-- !!! simple example of deriving Ord and Eq simultaneously
+--
+module ShouldSucceed where
+
+data Foo a b c
+ = C1 a Int
+ | C2 b Double
+ | C3 c String
+ deriving (Eq, Ord)
diff --git a/testsuite/tests/deriving/should_compile/drv004.stderr b/testsuite/tests/deriving/should_compile/drv004.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv004.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv005.hs b/testsuite/tests/deriving/should_compile/drv005.hs
new file mode 100644
index 0000000000..527dde98b9
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv005.hs
@@ -0,0 +1,6 @@
+-- !!! simple example of deriving Enum
+--
+module ShouldSucceed where
+
+data Foo = Foo1 | Foo2 | Foo3 | Foo4 | Foo5 | Foo6 | Foo7 | Foo8
+ deriving Enum
diff --git a/testsuite/tests/deriving/should_compile/drv005.stderr b/testsuite/tests/deriving/should_compile/drv005.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv005.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv006.hs b/testsuite/tests/deriving/should_compile/drv006.hs
new file mode 100644
index 0000000000..62f2cbcf67
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv006.hs
@@ -0,0 +1,9 @@
+-- !!! simple examples of deriving Ix
+--
+module ShouldSucceed where
+import Data.Ix
+
+data Foo = Foo1 | Foo2 | Foo3 | Foo4 | Foo5 | Foo6 | Foo7 | Foo8
+ deriving (Eq, Ord, Ix, Show)
+
+data Bar a b = MkBar a Int b Integer a
diff --git a/testsuite/tests/deriving/should_compile/drv006.stderr b/testsuite/tests/deriving/should_compile/drv006.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv006.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv007.hs b/testsuite/tests/deriving/should_compile/drv007.hs
new file mode 100644
index 0000000000..22da5b4aa3
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv007.hs
@@ -0,0 +1,6 @@
+-- !!! deriving Ord on d. type with a single nullary constructor.
+-- (from ghc-2.10 panic - as reported by Sergey Mechveliani <mechvel@botik.ru>)
+--
+module ShouldSucceed where
+
+data D = D deriving (Eq,Ord)
diff --git a/testsuite/tests/deriving/should_compile/drv007.stderr b/testsuite/tests/deriving/should_compile/drv007.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv007.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv008.hs b/testsuite/tests/deriving/should_compile/drv008.hs
new file mode 100644
index 0000000000..b615809caa
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv008.hs
@@ -0,0 +1,7 @@
+-- !!! deriving Ix on d. type with nullary constructors
+module ShouldSucceed where
+
+import Data.Ix
+
+data AD = A | B | C | D deriving (Show, Ord, Eq, Ix)
+
diff --git a/testsuite/tests/deriving/should_compile/drv008.stderr b/testsuite/tests/deriving/should_compile/drv008.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv008.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv009.hs b/testsuite/tests/deriving/should_compile/drv009.hs
new file mode 100644
index 0000000000..4ac069d30c
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv009.hs
@@ -0,0 +1,6 @@
+-- !!! deriving Ix on d. type with one constructor
+module ShouldSucceed where
+
+import Data.Ix
+
+data Pair a b = Pair a b deriving (Show, Ord, Eq, Ix)
diff --git a/testsuite/tests/deriving/should_compile/drv009.stderr b/testsuite/tests/deriving/should_compile/drv009.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv009.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv010.hs b/testsuite/tests/deriving/should_compile/drv010.hs
new file mode 100644
index 0000000000..1a3f9dc33a
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv010.hs
@@ -0,0 +1,4 @@
+-- !!! deriving Enum on d. type with nullary constructors
+module ShouldSucceed where
+
+data AD = A | B | C | D deriving (Enum)
diff --git a/testsuite/tests/deriving/should_compile/drv010.stderr b/testsuite/tests/deriving/should_compile/drv010.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv010.stderr
diff --git a/testsuite/tests/deriving/should_compile/drv011.hs b/testsuite/tests/deriving/should_compile/drv011.hs
new file mode 100644
index 0000000000..bba25f5cae
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv011.hs
@@ -0,0 +1,6 @@
+-- !!! deriving Enum, but not Ord.
+module ShouldSucceed where
+
+data ABC = A | B | C deriving Enum
+
+x = [A ..C]
diff --git a/testsuite/tests/deriving/should_compile/drv012.hs b/testsuite/tests/deriving/should_compile/drv012.hs
new file mode 100644
index 0000000000..eb8f3847cd
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv012.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE GADTs #-}
+
+-- !!! deriving for GADTs which declare Haskell98 data types.
+-- bug reported as http://hackage.haskell.org/trac/ghc/ticket/902
+module ShouldSucceed where
+
+data Maybe1 a where {
+ Nothing1 :: Maybe1 a ;
+ Just1 :: a -> Maybe1 a
+ } deriving (Eq,Ord)
diff --git a/testsuite/tests/deriving/should_compile/drv013.hs b/testsuite/tests/deriving/should_compile/drv013.hs
new file mode 100644
index 0000000000..1686bcc232
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv013.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
+-- Deriving Typeable has various special cases
+module Foo where
+
+import Data.Typeable
+
+data Foo1 = Foo1 deriving( Typeable )
+data Foo2 a = Foo2 a deriving( Typeable )
+data Foo3 a b = Foo3 a b deriving( Typeable )
+
diff --git a/testsuite/tests/deriving/should_compile/drv014.hs b/testsuite/tests/deriving/should_compile/drv014.hs
new file mode 100644
index 0000000000..12e2a15b3f
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv014.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE StandaloneDeriving, GeneralizedNewtypeDeriving #-}
+
+module ShouldCompile where
+
+data T a = T1 a | T2
+newtype N = MkN Int
+
+deriving instance Eq a => Eq (T a)
+deriving instance Num N
+deriving instance Eq N
+deriving instance Show N
diff --git a/testsuite/tests/deriving/should_compile/drv015.hs b/testsuite/tests/deriving/should_compile/drv015.hs
new file mode 100644
index 0000000000..f8cfbce2db
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv015.hs
@@ -0,0 +1,14 @@
+
+-- July 07: I'm changing this from "should_compile" to "should_fail".
+-- It would generate an instance decl like
+-- insance (Show (f a), Show (g a)) => Show (Pair1 f g a)
+-- and that is not Haskell 98.
+--
+-- See Note [Exotic derived instance contexts] in TcSimplify.
+-- The rule is simple: the context of a derived instance decl must
+-- contain constraints of form (C tyvar) only, just as H98.
+
+module ShouldCompile where
+
+newtype Pair1 f g a = Pair1 {unPair1 :: (f a, g a)}
+ deriving (Eq, Ord, Show)
diff --git a/testsuite/tests/deriving/should_compile/drv020.hs b/testsuite/tests/deriving/should_compile/drv020.hs
new file mode 100644
index 0000000000..8794b745e5
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv020.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
+ FlexibleInstances, GeneralizedNewtypeDeriving #-}
+
+-- Test deriving of a multi-parameter class for
+-- one-argument newtype defined in the same module
+module ShouldSucceed where
+
+-- library stuff
+
+class Monad m => MonadState s m | m -> s where
+ get :: m s
+ put :: s -> m ()
+
+newtype State s a = State {
+ runState :: (s -> (a, s))
+ }
+
+instance Monad (State s) where
+ return a = State $ \s -> (a, s)
+ m >>= k = State $ \s -> let
+ (a, s') = runState m s
+ in runState (k a) s'
+
+instance MonadState s (State s) where
+ get = State $ \s -> (s, s)
+ put s = State $ \_ -> ((), s)
+
+-- test code
+
+newtype Foo a = MkFoo (State Int a)
+ deriving (Monad, MonadState Int)
+
+f :: Foo Int
+f = get
diff --git a/testsuite/tests/deriving/should_compile/drv021.hs b/testsuite/tests/deriving/should_compile/drv021.hs
new file mode 100644
index 0000000000..c9800508de
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/drv021.hs
@@ -0,0 +1,16 @@
+{-# OPTIONS_GHC -XDeriveDataTypeable -XStandaloneDeriving #-}
+
+-- See Trac #1825
+-- Test stand-alone deriving for Typeable
+-- Horridly, one needs to define instance for Typeable1 etc
+
+module ShouldCompile where
+
+import Data.Typeable
+
+data T1 a = T1 a
+data T2 a b = T2 a b
+
+deriving instance Typeable1 T1
+deriving instance Typeable2 T2
+