拥有相应数据类型族
X
的类型类C
需要函数coerceX
。如果我按照下面的方式实现类型类,那么我该如何编写coerceX
函数?{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
import Data.Type.Coercion
import Control.Monad.Reader
data (T r t)
class C t where
data X t :: * -> *
coerceX :: Coercion a b -> Coercion (X t a) (X t b)
instance (C t) => C (T r t) where
newtype X (T r t) a = X (Reader r (X t a))
coerceX = ...