testsuite: Assert that testsuite ways are known
[ghc.git] / testsuite / tests / typecheck / should_compile / tc137.hs
1 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
2 FlexibleInstances #-}
3 {-# OPTIONS -dcore-lint #-}
4
5 {- This one killed GHC 5.02
6
7 The problem is that in rather obscure cases (involving functional
8 dependencies) it is possible to get an AbsBinds [] [] (no tyvars, no
9 dicts) which nevertheless has some "dictionary bindings". These come
10 out of the typechecker in non-dependency order, so we need to Rec them
11 just in case. Otherwise we get a CoreLint out-of-scope error.
12
13 Reported by Armin Groesslinger
14
15 -}
16
17 module ShouldCompile
18 where
19
20 data X a = X a
21
22 class Y a b | a -> b where
23 y :: a -> X b
24
25 instance Y [[a]] a where
26 y ((x:_):_) = X x
27
28 g :: Num a => [X a] -> [X a]
29 g xs = h xs
30 where
31 h ys = ys ++ map (k (y [[0]])) xs
32
33 k :: X a -> X a -> X a
34 k _ _ = y ([] ++ [[]] ++ [])