testsuite: Assert that testsuite ways are known
[ghc.git] / testsuite / tests / typecheck / should_compile / T7220.hs
1 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE FunctionalDependencies #-}
4 {-# LANGUAGE MultiParamTypeClasses #-}
5 {-# LANGUAGE RankNTypes #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# LANGUAGE ScopedTypeVariables #-}
8
9 module Test2 where
10
11 class C a b | b -> a
12
13 data A = A
14 data X a = X
15 data Y = Y
16
17 type family TF b
18
19 f :: (forall b. (C a b, TF b ~ Y) => b) -> X a
20 f _ = undefined
21
22 u :: (C A b, TF b ~ Y) => b
23 u = undefined
24
25 v :: X A
26 v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X A) u -- This line causes an error (see below)
27
28 {-
29 GHC 7.6.1-rc1 (7.6.0.20120810) rejects this code with the following error message.
30
31 Test2.hs:24:52:
32 Couldn't match expected type `Y'
33 with actual type `TF (forall b. (C A b, TF b ~ Y) => b)'
34 In the first argument of `f ::
35 (forall b. (C A b, TF b ~ Y) => b) -> X', namely
36 `u'
37 In the expression: (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u
38 In an equation for `v':
39 v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u
40
41 GHC 7.4.1 rejected this code with a different error message:
42
43 Test2.hs:24:6:
44 Cannot deal with a type function under a forall type:
45 forall b. (C A b, TF b ~ Y) => b
46 In the expression: f :: (forall b. (C A b, TF b ~ Y) => b) -> X
47 In the expression: (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u
48 In an equation for `v':
49 v = (f :: (forall b. (C A b, TF b ~ Y) => b) -> X) u
50 -}