testsuite: Assert that testsuite ways are known
[ghc.git] / testsuite / tests / typecheck / should_compile / tc176.hs
1 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
2 {-# LANGUAGE FlexibleInstances #-}
3
4 {- With "hugs -98 +o test.hs" gives me:
5 ERROR "test.hs":8 - Cannot justify constraints in instance member binding
6 *** Expression : fromStr
7 *** Type : FromStr [a] => String -> [a]
8 *** Given context : FromStr [a]
9 *** Constraints : FromStr [a]
10
11 Adding the constraint "FromStr a" to the declaration of fromStr fixes
12 the problem, but that seems like it should be redundant. Removing the
13 second instance (lines 10-11) also fixes the problem, interestingly enough.
14
15 /Bjorn Bringert -}
16
17 -- August 08: on reflection I think a complaint about overlapping
18 -- instances for line 8 is absolutely right, so I've changed this to
19 -- expected-failure
20
21 -- Sept 08: on further reflection (!) I'm changing it back
22 -- See Note [Subtle interaction of recursion and overlap]
23 -- in TcInstDcls
24
25 module ShouldCompile where
26
27 class FromStr a where
28 fromStr :: String -> a
29
30 typeError :: FromStr a => a -> a
31 typeError t = error "type error"
32
33 instance {-# OVERLAPPABLE #-} FromStr [a] where
34 fromStr _ = typeError undefined -- line 8
35
36 instance {-# OVERLAPPING #-} FromStr [(String,a)] where -- line 10
37 fromStr _ = typeError undefined -- line 11