blob: 232ea6bec29c6d7b93120262a52d363cd53e61c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
{-# LANGUAGE TypeFamilies, GADTs, ConstraintKinds, RankNTypes #-}
module T5655 where
import GHC.Prim (Constraint)
class Show a => Twice a where twice :: a -> a
instance Twice Int where twice = (*2)
data ETwice where ETwice :: Twice a => a -> ETwice
class E e where
type C e :: * -> Constraint
ap :: (forall a. C e a => a -> r) -> e -> r
instance E ETwice where
type C ETwice = Twice
ap f (ETwice a) = f a
f :: (E e, C e ~ Twice) => e -> ETwice
f = ap (ETwice . twice)
foo :: ETwice
foo = ETwice (5 :: Int)
bar = ap print (f foo)
|