Я пытаюсь разобрать JSON-представление RoseTree. Вот снимок у меня есть:Parsing RoseTree JSON в Haskell
module RoseTree2 where
import Data.Tree
import Data.Aeson
import qualified Data.Text as T
import Control.Applicative
data RoseTree2 = RoseNode Int [RoseTree2] deriving (Show)
instance ToJSON RoseTree2 where
toJSON (RoseNode n cs) =
object [T.pack "value" .= show n
, T.pack "children".= show cs]
instance FromJSON RoseTree2 where
parseJSON (Object o) =
RoseNode <$> o.: T.pack "value"
<*> o.: T.pack "children"
Но я получаю следующее сообщение об ошибке на fileload:
RoseTree2.hs:10:10:
No instance for (GToJSON (GHC.Generics.Rep RoseTree2))
arising from a use of `aeson-0.7.0.6:Data.Aeson.Types.Class.$gdmtoJSON'
Possible fix:
add an instance declaration for
(GToJSON (GHC.Generics.Rep RoseTree2))
In the expression:
(aeson-0.7.0.6:Data.Aeson.Types.Class.$gdmtoJSON)
In an equation for `toJSON':
toJSON = (aeson-0.7.0.6:Data.Aeson.Types.Class.$gdmtoJSON)
In the instance declaration for `ToJSON RoseTree2'
Failed, modules loaded: none.
Может порадовать кто-то сказать мне, что случилось с моим определением JSON парсер и как я могу это исправить ? Благодаря!