blob: ffa2f927e364647f13e306baa613006f17cfa1bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-- Should AllowAmbiguousTypes really be needed here?
{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances, AllowAmbiguousTypes #-}
module T11347 where
newtype Id1 a = MkId1 a
newtype Id2 a = MkId2 (Id1 a) deriving (UnsafeCast b)
type family Discern a b
type instance Discern (Id1 a) b = a
type instance Discern (Id2 a) b = b
class UnsafeCast to from where
unsafe :: from -> Discern from to
instance UnsafeCast b (Id1 a) where
unsafe (MkId1 x) = x
unsafeCoerce :: a -> b
unsafeCoerce x = unsafe (MkId2 (MkId1 x))
|