[Haskell-cafe] How to make this data type work?
Magicloud Magiclouds
magicloud.magiclouds at gmail.com
Fri Jun 21 10:14:12 CEST 2013
data ActionData = AD { oldData :: (FromJSON j, ToJSON j) => j
, newData :: (FromJSON j, ToJSON j) => j}
instance ToJSON ActionData where
toJSON (AD o n) = object [ "oldData" .= o
, "newData" .= n ]
instance FromJSON ActionData where
parseJSON (Object v) = AD
<$> v .: "oldData"
<*> v .: "newData"
parseJSON _ = mzero
I got when compile:
No instance for (FromJSON (forall j. (FromJSON j, ToJSON j) => j))
arising from a use of `.:'
Possible fix:
add an instance declaration for
(FromJSON (forall j. (FromJSON j, ToJSON j) => j))
In the second argument of `(<$>)', namely `v .: "oldData"'
In the first argument of `(<*>)', namely `AD <$> v .: "oldData"'
In the expression: AD <$> v .: "oldData" <*> v .: "newData"
--
竹密岂妨流水过
山高哪阻野云飞
And for G+, please use magiclouds#gmail.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130621/0adfb7d0/attachment.htm>
More information about the Haskell-Cafe
mailing list