Complete work on new OVERLAPPABLE/OVERLAPPING pragmas (Trac #9242)
[ghc.git] / testsuite / tests / typecheck / should_compile / tc179.hs
1 {-# LANGUAGE ExistentialQuantification, FlexibleInstances, UndecidableInstances #-}
2
3 -- Tests context reduction for existentials
4
5 module TestWrappedNode where
6
7 class Foo a where { op :: a -> Int }
8
9 instance {-# OVERLAPPABLE #-} Foo a => Foo [a] where -- NB overlap
10 op (x:xs) = op x
11 instance {-# OVERLAPPING #-} Foo [Int] where -- NB overlap
12 op x = 1
13
14 data T = forall a. Foo a => MkT a
15
16 f :: T -> Int
17 f (MkT x) = op [x,x]
18 -- The op [x,x] means we need (Foo [a]). We used to
19 -- complain, saying that the choice of instance depended on
20 -- the instantiation of 'a'; but of course it isn't *going*
21 -- to be instantiated.
22