1 year ago
#358035
RandomB
Why automatical deriving for newtype does not work
I use library msgpack-types-0.0.4 and I have a type:
newtype A = A Text
and I tried deriving MessagePack
, deriving newtype MessagePack
, standalone derivings, it seems nothing works (or I do something wrong). There is MessagePack
instances for Text
, for String
, I thought that newtype
deriving works always... Is it possible to derive this instance automatically? Why does not it work with newtype
deriving?
EDIT:
An error message:
for newtype A = A Text deriving newtype MessagePack
:
• Couldn't match representation of type ‘m Text’ with that of ‘m A’
arising from the coercion of the method ‘fromObject’
from type ‘forall (m :: * -> *).
(Applicative m, Monad m, MonadFail m) =>
Data.MessagePack.Object -> m Text’
to type ‘forall (m :: * -> *).
(Applicative m, Monad m, MonadFail m) =>
Data.MessagePack.Object -> m A’
NB: We cannot know what roles the parameters to ‘m’ have;
we must assume that the role is nominal
• When deriving the instance for (MessagePack A)
haskell
deriving
0 Answers
Your Answer