Fix incorrect ambiguity error on identically-named data constructors
[ghc.git] / testsuite / tests / typecheck / should_fail / tcfail080.hs
1 {-# LANGUAGE MultiParamTypeClasses #-}
2
3 -- !!! Multi-param type classes test: ambiguity bug
4
5 -- GHC actually accepts this program because
6 -- q :: Collection c a => a -> Bool
7 -- and there is no a priori reason to suppose that
8 -- q would be ambiguous in every context. For example,
9 -- it could be fine if we had
10 -- instance c Int where ...
11 -- Of course, it'd be hard to fill in the "..." in this particular
12 -- case, but that relies on observations about the form of the types
13 -- of the class methods, surely beyond what a compiler should do.
14 --
15 -- Still, the type is ambiguous because there's nothing to fix 'c'
16
17
18 module ShouldFail where
19
20 class Collection c a where
21 empty :: c a
22 add :: a -> c a -> c a
23 isempty :: c a -> Bool
24
25 singleton x = add x empty
26
27 q x = isempty (singleton x)
28
29