356fc728e02b3b19f7163e32c5eaee9a297b4ef6
[ghc.git] / testsuite / tests / typecheck / should_compile / LoopOfTheDay2.hs
1 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
2 {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}
3
4 -- Compilation loops in GHC 6.2!
5 -- While LoopOfTheDay1.hs did compile and work,
6 -- this one loops during compilation, even though
7 -- there is only an innocent difference regarding T1,
8 -- i.e., an additional, non-recursive constructor component.
9
10 module ShouldCompile where
11
12 data T1 = T1a Int | T1b T1
13
14 class C0 x where foo :: x -> (); foo = undefined
15 -- foo :: C0 x => x -> ()
16
17 class C1 x y
18 class C1 x y => C2 x y
19
20 instance C0 Int => C1 () Int -- I1
21 instance C0 T1 => C1 () T1 -- I2
22 instance (C1 x T1, C1 x Int) => C2 x T1 -- I3
23 instance C1 x Int => C2 x Int -- I4
24 instance C2 () T1 => C0 T1 -- I5
25 instance C2 () Int => C0 Int -- I6
26
27
28 baz = foo (T1b (T1a 3))
29
30 {- Need
31 C0 T1
32 -->(I5) C2 () T1
33 -->(I3) C1 () T1, C1 () Int
34 -->(I1,I2) C0 T1, C0 Int
35 -->(recusive) C0 Int
36 -->(I6) C2 () Int
37 -->(I4) C1 () Int
38 -->(recursive) {}
39 -}