It is not so difficult to write ToJSON / FromJSON instances for the generated types, but still, while you are generating the code, can you insert it? Or is there an easy way to do this as a Yesod user? (I'm not too deep into how TH works ...)
Update: Well, I like this sentence, but let's say my constant type is User. If i use
$(deriveJSON id ''User)
He gives
Exception when trying to run compile-time code: Data.Aeson.TH.withType: Unsupported type: TySynD Model.User [] (AppT (ConT Model.UserGeneric) (ConT Database.Persist.GenericSql.Raw.SqlPersist)) Code: deriveJSON (id) 'User
obviously because it is a pseudonym. But
$(deriveJSON id ''UserGeneric)
gives
Kind mis-match The first argument of `UserGeneric' should have kind `(* -> *) -> * -> *', but `backend[i5XB]' has kind `*'
I probably still have the wrong type, but I can't find enough of what Persistent generates to get the right spell.
source share