the issue in both cases is that you're applying ToJSON to two arguments - StudentReport and a, while ToJSON has only one argument - the type you're serialising
I'm guessing you actually want instance ToJSON a => ToJSON (StudentReport a) - now this is an application of ToJSON to the type StudentReport a
Hi, I'm using a parametric type in my code :
However I'd like to be able to serialize such type to JSON sometimes, using aeson ToJSON typeclass.
How can I do that ? I tried
But it doesn't work (Expected kind ‘* -> Constraint’, but ‘ToJSON StudentReport’ has kind ‘Constraint’)
I also tried
but it doesn't work either ( Expected kind ‘k0 -> Constraint’, but ‘ToJSON StudentReport’ has kind ‘Constraint’)
the issue in both cases is that you're applying
ToJSON
to two arguments -StudentReport
anda
, whileToJSON
has only one argument - the type you're serialisingI'm guessing you actually want
instance ToJSON a => ToJSON (StudentReport a)
- now this is an application ofToJSON
to the typeStudentReport a
these are the same rules that apply to terms
fact pred n
isfact
applied topred
andn
, notfact
applied topred n
- you wantfact (pred n)
insteadit works ! thanks !
I forgot to check the "operator precedence" of ToJSON