Consider switching back to aeson-generated json serialization? #109
Description
#107 caused me to consider code generation for other editors to be an advantage of generated JSON instances. Once more editor code is written, it'd be good not to have sweeping changes to the protocol, so we ought to be sure the current approach is best. Despite the consensus in #32, it seems worthwhile to revisit the decision.
Pros
- Allows for generating serialization code for editors (somewhat related to [RFC] Ide generation and Guidance Proposition #107). Code generators for aeson's default serialization would generally be a very useful thing to have.
- Reduces boilerplate
- If consistent type / field naming is used in Haskell, we also get consistent JSON naming.
Cons
- Potentially uglier JSON
Solvable Cons
- Easier to accidentally change the protocol
-
Solution: Generate a file every compilation, possibly by
pprint
ing all of the types, sorted by name. Stuff that isn't relative to serialization, such as which instances are derived, would get set to some default ([]
).The file would be part of the repo and would store a protocol version number. When this file differs from the HEAD version of the file, it'll force a version bump. Some differences may be benign. In this case, you can force the version number back to what it was, and commit the new version of the file.
The file could also store an aeson version number. While this usually shouldn't make a difference to the protocol, it would be a good idea to make sure that aeson didn't change any serialization details when upgrading it.
-
- Can't have
FromJSON
instance take old formats.- Solution: Keep the generated
ToJSON
instance, and add an explicitFromJSON
instance. This way, code generation will still work.
- Solution: Keep the generated