Add instances for Records using RowToList
FrigoEU opened this issue ยท 6 comments
The library purescript-simple-json has instances to encode and decode records using RowToList. Would it be a good idea to add these also to Argonaut? I'm willing to make a PR, but I'd like to know if it would be useful first.
I don't really have any strong feelings about how any of this library should work anymore, as I/we at SlamData use the slightly confusingly named purescript-codec-argonaut instead ๐
I think it's probably a reasonable thing to have though, yeah, since there's a sensible expected encoding and decoding from JSON.
Oh, I had no idea about that library. I'll look into it.
It needs some explanation / docs really. ๐
But mainly it has a bit of a different philosophy, codecs are values, and everything has to be defined explicitly.
One advantage is the codecs defined with the provided combinators are guaranteed to roundtrip, so you only need one definition.
The other thing is we want everything to be explicit, as we have a serialization format that we need to avoid breaking between versions - with the "automatic" instance-based approach sometimes changes to the types don't require changes to the codec instances, which led to inadvertent backwards-incompatible changes occasionally. (Plus there's some utils included for making "migration codecs" to upgrade from an old format to make it compatible with a new one).
Not ready for a proper PR yet but for reference here's the kind of thing that would be involved for encodeJson at least: master...elliotdavies:feature/record-codecs
Closed in #46