Ticket #7220: Test2.hs

File Test2.hs, 1.4 KB (added by tsuyoshi, 3 years ago)
Line 
1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FunctionalDependencies #-}
3{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE TypeFamilies #-}
6
7module Test2 where
8
9class C a b | b -> a
10
11data A = A
12data X = X
13data Y = Y
14
15type family TF b
16
17f :: (forall b. (C a b, TF b ~ Y) => b) -> X
18f _ = undefined
19
20u :: (C A b, TF b ~ Y) => b
21u = undefined
22
23v :: X
24v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u -- This line causes an error (see below)
25
26{-
27GHC 7.6.1-rc1 (7.6.0.20120810) rejects this code with the following error message.
28
29Test2.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
39GHC 7.4.1 rejected this code with a different error message:
40
41Test2.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-}