summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs')
-rw-r--r--testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs b/testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs
new file mode 100644
index 0000000000..0996e7c2f2
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/LoopOfTheDay2.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}
+
+-- Compilation loops in GHC 6.2!
+-- While LoopOfTheDay1.hs did compile and work,
+-- this one loops during compilation, even though
+-- there is only an innocent difference regarding T1,
+-- i.e., an additional, non-recursive constructor component.
+
+module ShouldCompile where
+
+data T1 = T1a Int | T1b T1
+
+class C0 x where foo :: x -> (); foo = undefined
+-- foo :: C0 x => x -> ()
+
+class C1 x y
+class C1 x y => C2 x y
+
+instance C0 Int => C1 () Int -- I1
+instance C0 T1 => C1 () T1 -- I2
+instance (C1 x T1, C1 x Int) => C2 x T1 -- I3
+instance C1 x Int => C2 x Int -- I4
+instance C2 () T1 => C0 T1 -- I5
+instance C2 () Int => C0 Int -- I6
+
+
+baz = foo (T1b (T1a 3))
+
+{- Need
+ C0 T1
+-->(I5) C2 () T1
+-->(I3) C1 () T1, C1 () Int
+-->(I1,I2) C0 T1, C0 Int
+-->(recusive) C0 Int
+-->(I6) C2 () Int
+-->(I4) C1 () Int
+-->(recursive) {}
+-}