Add kind equalities to GHC.
[ghc.git] / testsuite / tests / typecheck / should_compile / T5655.hs
1 {-# LANGUAGE TypeFamilies, GADTs, ConstraintKinds, RankNTypes #-}
2 module T5655 where
3
4 import Data.Kind (Constraint)
5
6 class Show a => Twice a where twice :: a -> a
7
8 instance Twice Int where twice = (*2)
9
10 data ETwice where ETwice :: Twice a => a -> ETwice
11
12 class E e where
13 type C e :: * -> Constraint
14 ap :: (forall a. C e a => a -> r) -> e -> r
15
16 instance E ETwice where
17 type C ETwice = Twice
18 ap f (ETwice a) = f a
19
20 f :: (E e, C e ~ Twice) => e -> ETwice
21 f = ap (ETwice . twice)
22
23 foo :: ETwice
24 foo = ETwice (5 :: Int)
25
26 bar :: IO ()
27 bar = ap print (f foo)