summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc179.hs
blob: 110950587de43f2e80c920a5e5c1f075d256190a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE ExistentialQuantification, FlexibleInstances,
             OverlappingInstances, UndecidableInstances #-}

-- Tests context reduction for existentials

module TestWrappedNode where

class Foo a where { op :: a -> Int }

instance Foo a => Foo [a] where  	-- NB overlap
  op (x:xs) = op x
instance Foo [Int] where		-- NB overlap
  op x = 1

data T = forall a. Foo a => MkT a

f :: T -> Int
f (MkT x) = op [x,x]
	-- The op [x,x] means we need (Foo [a]).  We used to 
	-- complain, saying that the choice of instance depended on 
	-- the instantiation of 'a'; but of course it isn't *going* 
	-- to be instantiated.