blob: 62db4726a03561f05de4d5dadb2f38d7cea9c639 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
{-# LANGUAGE ExistentialQuantification, FlexibleInstances, UndecidableInstances #-}
-- Tests context reduction for existentials
module TestWrappedNode where
class Foo a where { op :: a -> Int }
instance {-# OVERLAPPABLE #-} Foo a => Foo [a] where -- NB overlap
op (x:xs) = op x
instance {-# OVERLAPPING #-} 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.
|