I have a query with the following type
sql :: Query '[] with MySchema '[ 'NotNull 'PGint4] '["id" ::: 'NotNull 'PGint4, "vals" ::: 'NotNull 'PGjsonb]
that I then want to turn into a Statement
getValues :: Statement MySchema Int32 (Int32, Aeson.Value)
getValues = Query encode decode sql
where
encode = (\x -> x) .* nilParams
decode = (,) <$> #id <*> #vals
This gives me the following error though
* Couldn't match type `PGjsonb' with `PGjson'
arising from the overloaded label `#vals'
* In the second argument of `(<*>)', namely `#vals'
In the expression: (,) <$> #id <*> #vals
In an equation for `decode': decode = (,) <$> #id <*> #vals
which confuses me. The schema says the field is PGjsonb
, the query typechecks and the value is PGjsonb
, so where does PGjson
come in? How do I convert a PGjsonb
field to an Aeson.Value
? I’m clearly missing something here, but what?
(I originally posted this question here, but thought I’d widen the audience a bit.)