SCC analysis for instances as well as types/classes
[ghc.git] / testsuite / tests / typecheck / should_compile / tc235.hs
1 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
2 {-# LANGUAGE FlexibleInstances, UndecidableInstances,
3 MultiParamTypeClasses, FunctionalDependencies #-}
4 {-# LANGUAGE AllowAmbiguousTypes #-}
5 -- 'x' and 'v' are ambiguous
6
7 -- Trac #1564
8
9 module Foo where
10
11 import Text.PrettyPrint
12 import Prelude hiding(head,tail)
13
14 class FooBar m k l | m -> k l where
15 a :: m graphtype
16
17 instance FooBar [] Bool Bool where
18 a = error "urk"
19
20 instance FooBar Maybe Int Int where
21 a = error "urk"
22
23 class (Monad m)=>Gr g ep m where
24 x:: m Int
25 v:: m Int
26
27 instance (Monad m, FooBar m x z) => Gr g ep m where
28 x = error "urk"
29 v = error "urk"
30
31 -- Old GHC claims for y: y :: (Monad m, FooBar m GHC.Prim.Any GHC.Prim.Any)
32 -- => m Int (which is wrong)
33 -- The uses in foo and bar show if that happens
34 y () = x
35
36 foo :: [Int]
37 foo = y ()
38
39 bar :: Maybe Int
40 bar = y ()
41
42