To answer the immediate question, replace ??? by any type that's an instance of both Typeable
and ToJSON
. The code will typecheck if you use String
, for instance.
Regarding your goal, if the expressions you want to interpret can actually have different types it looks like this approach won't work directly. Since you're interpreting already, I suggest doing the JSON conversion within the interpreter. Something along the lines of prepending interpExpr
with toJSON $
and replacing ??? by Value
.