Complete work on new OVERLAPPABLE/OVERLAPPING pragmas (Trac #9242)
[ghc.git] / testsuite / tests / typecheck / should_compile / T1470.hs
1 {-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, UndecidableInstances, KindSignatures #-}
2
3 -- Trac #1470
4
5 module Foo where
6
7 class Sat a
8 class Data (ctx :: * -> *) a
9 instance Sat (ctx Char) => Data ctx Char
10 instance (Sat (ctx [a]), Data ctx a) => Data ctx [a]
11
12 class Data FooD a => Foo a
13
14 data FooD a = FooD
15
16 instance Foo t => Sat (FooD t)
17
18 instance {-# OVERLAPPABLE #-} Data FooD a => Foo a
19 instance {-# OVERLAPS #-} Foo a => Foo [a]
20 instance {-# OVERLAPPING #-} Foo [Char]
21 {-
22 Given: Foo a,
23 and its superclasses: Data FooD a
24
25 Want superclass: Data FooD [a]
26
27 by instance Data FooD [a]
28 want: Sat (FooD [a])
29 Data FooD a -- We have this
30
31 by instance Sat (FooD t)
32 want: Foo [a]
33
34 BUT THIS INSTANCE OVERLAPS
35 -}
36