I would like to use derived instance like this:
data Test3D = forall a. (Show a, Eq a, Typeable a, Generic a)
=> Test3D { testDt :: String
, testPrm :: a
}
deriving (Show, Eq, Typeable, Generic)
instance Binary (Test3D)
$(deriveJSON defaultOptions ''Test3D)
But I received from GHC:
• Can't make a derived instance of ‘Show Test3D’:
Constructor ‘Test3D’ has existentials or constraints in its type
Possible fix: use a standalone deriving declaration instead
• In the data declaration for ‘Test3D’
This way is very convenient for my project. I can not find the solution.
Is any way of using derived instance for such data?
testPrm
. If you can't figure out how to do it, then GHC can't do it automatically for you. On the other hand, if you don't care about showingtestPrm
, then the instance is easy to write by hand and you don't need to derive it. – RestlessBinary
instance for everyGeneric
. It looks as a rather complex task. I think we can't realistically hope that the automagic deriving mechanism solved this for us. Perhaps we could manually write an easier instance if we useBinary a
instead ofGeneric a
? – Semifluid