Improve error messages around kind mismatches.
[ghc.git] / testsuite / tests / typecheck / should_fail / T9858a.hs
1 -- From comment:76 in Trac #9858
2 -- This exploit still works in GHC 7.10.1.
3 -- By Shachaf Ben-Kiki, Ørjan Johansen and Nathan van Doorn
4
5 {-# LANGUAGE Safe #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# LANGUAGE ConstraintKinds #-}
8 {-# LANGUAGE ImpredicativeTypes #-}
9
10 module T9858a where
11
12 import Data.Typeable
13
14 type E = (:~:)
15 type PX = Proxy (((),()) => ())
16 type PY = Proxy (() -> () -> ())
17
18 data family F p a b
19
20 newtype instance F a b PX = ID (a -> a)
21 newtype instance F a b PY = UC (a -> b)
22
23 {-# NOINLINE ecast #-}
24 ecast :: E p q -> f p -> f q
25 ecast Refl = id
26
27 supercast :: F a b PX -> F a b PY
28 supercast = case cast e of
29 Just e' -> ecast e'
30 where
31 e = Refl
32 e :: E PX PX
33
34 uc :: a -> b
35 uc = case supercast (ID id) of UC f -> f