774d5f38010dfd42448d389048bb501382a535db
[ghc.git] / testsuite / tests / typecheck / should_compile / T3108.hs
1 {-# LANGUAGE OverlappingInstances, UndecidableInstances, MultiParamTypeClasses,
2 FunctionalDependencies, FlexibleInstances #-}
3
4 module T3108 where
5
6 -- Direct recursion terminates (typechecking-wise)
7
8 class C0 x
9 where
10 m0 :: x -> ()
11 m0 = const undefined
12
13 instance (C0 x, C0 y) => C0 (x,y)
14 instance C0 Bool
15 instance C0 (x,Bool) => C0 x
16
17 foo :: ()
18 foo = m0 (1::Int)
19
20
21 -- Indirect recursion does not terminate (typechecking-wise)
22
23 class C1 x
24 where
25 m1 :: x -> ()
26 m1 = const undefined
27
28 instance (C1 x, C1 y) => C1 (x,y)
29 instance C1 Bool
30 instance (C2 x y, C1 (y,Bool)) => C1 x
31
32 class C2 x y | x -> y
33 instance C2 Int Int
34
35 -- It is this declaration that causes nontermination of typechecking.
36 bar :: ()
37 bar = m1 (1::Int)