к
data Rad n where
Rad :: (Coercible Double n, RealFloat n)
=> n -> Rad n
deriving RealFloat via Double
GHC жалуется:
* Couldn't match representation of type `Double'
with that of `Deg n'
arising from the coercion of the method `floatRadix'
from type `Double -> Integer' to type `Deg n -> Integer'
* When deriving the instance for (RealFloat (Deg n))
Почему не совпадает, если я указал, что n и Double Coercible? Только потому, что не newtype, а data?
newtype Unshowable a = Unshowable a
instance Show (Unshowable a) where
show _ = "unshowable"
data X = Y
deriving Show via (Unshowable X)
то есть не важно, data или newtype - таргет для deriving via
важно, чтобы тип слева от deriving via был коерсибл в тип справа от deriving via