Testsuite: fixup lots of tests
[ghc.git] / testsuite / tests / deriving / should_run / T3087.hs
1 {-# LANGUAGE RankNTypes, DeriveDataTypeable #-}
2
3 module Main where
4
5 import Data.Generics hiding (ext2Q)
6
7 data MyMaybe a = MyNothing | MyJust a deriving (Data, Typeable)
8
9 test1 :: ()
10 test1 = undefined `ext1Q` (\ (Just _) -> ()) $ Just ()
11
12 test1' :: ()
13 test1' = undefined `ext1Q` (\ (MyJust _) -> ()) $ MyJust ()
14
15 newtype Q r a = Q { unQ :: a -> r }
16
17 ext2Q :: (Data d, Typeable2 t)
18 => (d -> q) -> (forall d1 d2. (Data d1, Data d2) => t d1 d2 -> q)
19 -> d -> q
20 ext2Q def ext arg =
21 case dataCast2 (Q ext) of
22 Just (Q ext') -> ext' arg
23 Nothing -> def arg
24
25 data MyPair a b = MyPair a b deriving (Data, Typeable)
26
27 test2 :: ()
28 test2 = undefined `ext2Q` (\(_,_) -> ()) $ ((),())
29
30 test2' :: ()
31 test2' = undefined `ext2Q` (\(MyPair _ _) -> ()) $ MyPair () ()
32
33 main = do { print test1; print test1'; print test2; print test2' }