-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reflect the internal (real) type of Value with a type parameter (like in GADTs for syntactic terms) #260
Comments
One problem with implementing such GADT annotations for But we might not care about deep type annotations, only use practically the one from the top only. And represent objects and arrays with elements of type Processing
|
Perhaps, we could live without GADTs, but with a bunch of classes like |
This is not a design space that aeson can explore, due to its backwards incompatibility. I recommend you try the idea out in a smaller, simpler package of your own and see how well it works in practice. |
Sometimes a JSON-based format dictates that we must have, say, a JSON "object" at some place (and other types would break the format).
It would be nice to make these things expressable in the Haskell types (with a type parameter of
Value
).Also often people want to re-use the result of
toJSON
, but they really expect a specific type when they deconstruct it. (Like in the motivation for #245, which I find quite ugly.) The compiler could check these assumptions and give guarantees.(I have a few examples of both kinds in my code: adhering to a stricter JSON format, and decontructing the result of
toJSON
.)Actually, sometimes there are different variants how to encode a data type; the Aeson options can control this. But one could perhaps even have several
ToJSON
instances for such data, if the class is parameterized with the type of the resulting JSON value.I'm not sure whether this can be done smoothly (automatically, with as little manual annotations as possible) with the Generics machinery.
The text was updated successfully, but these errors were encountered: