1 | {-# LANGUAGE FlexibleContexts #-} |
---|

2 | {-# LANGUAGE FunctionalDependencies #-} |
---|

3 | {-# LANGUAGE MultiParamTypeClasses #-} |
---|

4 | {-# LANGUAGE RankNTypes #-} |
---|

5 | {-# LANGUAGE TypeFamilies #-} |
---|

6 | |
---|

7 | module Test2 where |
---|

8 | |
---|

9 | class C a b | b -> a |
---|

10 | |
---|

11 | data A = A |
---|

12 | data X = X |
---|

13 | data Y = Y |
---|

14 | |
---|

15 | type family TF b |
---|

16 | |
---|

17 | f :: (forall b. (C a b, TF b ~ Y) => b) -> X |
---|

18 | f _ = undefined |
---|

19 | |
---|

20 | u :: (C A b, TF b ~ Y) => b |
---|

21 | u = undefined |
---|

22 | |
---|

23 | v :: X |
---|

24 | v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u -- This line causes an error (see below) |
---|

25 | |
---|

26 | {- |
---|

27 | GHC 7.6.1-rc1 (7.6.0.20120810) rejects this code with the following error message. |
---|

28 | |
---|

29 | Test2.hs:24:52: |
---|

30 | Couldn't match expected type `Y' |
---|

31 | with actual type `TF (forall b. (C A b, TF b ~ Y) => b)' |
---|

32 | In the first argument of `f :: |
---|

33 | (forall b. (C A b, TF b ~ Y) => b) -> X', namely |
---|

34 | `u' |
---|

35 | In the expression: (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u |
---|

36 | In an equation for `v': |
---|

37 | v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u |
---|

38 | |
---|

39 | GHC 7.4.1 rejected this code with a different error message: |
---|

40 | |
---|

41 | Test2.hs:24:6: |
---|

42 | Cannot deal with a type function under a forall type: |
---|

43 | forall b. (C A b, TF b ~ Y) => b |
---|

44 | In the expression: f :: (forall b. (C A b, TF b ~ Y) => b) -> X |
---|

45 | In the expression: (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u |
---|

46 | In an equation for `v': |
---|

47 | v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u |
---|

48 | -} |
---|