Ticket #5927: implies.hs

File implies.hs, 816 bytes (added by illissius, 2 years ago)
Line 
1{-# LANGUAGE ConstraintKinds, PolyKinds, FlexibleInstances, UndecidableInstances, TypeOperators, Rank2Types, MultiParamTypeClasses, CPP #-}
2
3type F c r = forall a. c a => a -> r
4
5class c `Implies` d where
6    foo :: F d r ->  F c r
7
8instance Ord `Implies` Eq where
9    foo f = f
10
11#ifdef FAIL
12instance Eq `Implies` Ord where
13    foo f = f
14#endif
15
16class    (c a, d a) => (c :&: d) a
17instance (c a, d a) => (c :&: d) a
18
19instance (c :&: d) `Implies` c where
20    foo f = f
21
22instance (c :&: d) `Implies` d where
23    foo f = f
24
25#ifdef FAIL
26instance c `Implies` (c :&: d) where
27    foo f = f
28
29instance d `Implies` (c :&: d) where
30    foo f = f
31#endif
32
33class Foo a
34
35instance Show a => Foo a
36
37instance Show `Implies` Foo where
38    foo f = f
39
40#ifdef FAIL
41instance Foo `Implies` Show where
42    foo f = f
43#endif
44
45main = print 9
46