hadrian: Add support for bindist compressors other than Xz
[ghc.git] / testsuite / tests / typecheck / should_compile / tc216.hs
1 {-# LANGUAGE UndecidableInstances, FlexibleInstances,
2 MultiParamTypeClasses, FunctionalDependencies #-}
3
4 -- Test for trac #816
5 -- GHC's typechecker loops when trying to type this, resulting in a
6 -- context stack overflow.
7
8 {- Maybe this should typecheck:
9
10 Given: Foo x y, Bar y z
11 Wanted: Foo x beta, Bar beta z
12
13 If we happened to process (Foo x beta) first we
14 might generate the extra equality beta~y, and we are good
15
16 If we process (Bar beta z) first, we end up in an infinite
17 loop, using the (Bar x z) instance repeatedly.
18
19 If instead we'd had
20 class (F x ~ y) => Foo x y where
21 type F x
22 foo :: x -> y
23
24 Then after canonicalising we get
25 Given: Foo x y, Bar y z, F x ~ y
26 Wanted: Foo x beta, Bar beta z
27 -}
28
29 module ShouldCompile where
30
31 class Foo x y | x -> y where
32 foo :: x -> y
33
34 class Bar x z where
35 bar :: x -> z -> Int
36
37 instance (Foo x y, Bar y z) => Bar x z where
38 bar x z = bar (foo x) z
39