Skip to content
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

Add instances for Records using RowToList #37

Closed
FrigoEU opened this issue Jan 19, 2018 · 6 comments

Comments

@FrigoEU
Copy link

commented Jan 19, 2018

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.

@garyb

This comment has been minimized.

Copy link
Member

commented Jan 20, 2018

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.

@FrigoEU

This comment has been minimized.

Copy link
Author

commented Jan 20, 2018

Oh, I had no idea about that library. I'll look into it.

@garyb

This comment has been minimized.

Copy link
Member

commented Jan 20, 2018

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).

@elliotdavies

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2018

I think providing some general-purpose instances for records would be sensible - it's probably a bit surprising that they're not there, actually. I can see about doing a PR for them?

/cc @FrigoEU @garyb

@elliotdavies

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2018

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

@thomashoneyman

This comment has been minimized.

Copy link
Member

commented Nov 9, 2018

Closed in #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.