summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/typecheck/should_fail/tcfail080.hs
blob: b2a62cea54629f2827c0b0017dcf781831acef69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE MultiParamTypeClasses #-}

-- !!! Multi-param type classes test: ambiguity bug

-- GHC actually accepts this program because
--	q :: Collection c a => a -> Bool
-- and there is no a priori reason to suppose that
-- q would be ambiguous in every context. For example,
-- it could be fine if we had
--	instance c Int where ...
-- Of course, it'd be hard to fill in the "..." in this particular
-- case, but that relies on observations about the form of the types
-- of the class methods, surely beyond what a compiler should do.
-- That's why GHC accepts it

module ShouldFail where

class Collection c a where
    empty :: c a
    add :: a -> c a -> c a
    isempty :: c a -> Bool

singleton x = add x empty

q x = isempty (singleton x)