Fix impredicativity (again)
[ghc.git] / testsuite / tests / typecheck / should_fail / T11347.hs
1 -- Should AllowAmbiguousTypes really be needed here?
2 {-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances, AllowAmbiguousTypes #-}
3 module T11347 where
4
5 newtype Id1 a = MkId1 a
6 newtype Id2 a = MkId2 (Id1 a) deriving (UnsafeCast b)
7
8 type family Discern a b
9 type instance Discern (Id1 a) b = a
10 type instance Discern (Id2 a) b = b
11
12 class UnsafeCast to from where
13 unsafe :: from -> Discern from to
14
15 instance UnsafeCast b (Id1 a) where
16 unsafe (MkId1 x) = x
17
18 unsafeCoerce :: a -> b
19 unsafeCoerce x = unsafe (MkId2 (MkId1 x))