-
Notifications
You must be signed in to change notification settings - Fork 533
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 a type class combining encoding and decoding #133
Comments
FWIW I just went through this in reverse with doobie (and had a good discussion with @mpilquist who went through a similar exercise with scodec). My approach is:
In my case you almost always have read/write pairs so getting rid of |
Also if you add |
Done in #1151. |
Rob Norris's third bullet point, circe/circe#133 (comment), motivated this change.
Add back language: scala
Today on Gitter @julienrf asked the following question:
And my response:
My wishlist for a
Codec
type class in circe would look something like this:Codec[A]
should be available (without any imports) for anyA
that has aDecoder
andEncoder
—i.e. ifio.circe.Decoder[A]
andio.circe.Encoder[A]
compile, thenio.circe.Codec[A]
must compile as well.Codec
instance, then asking for aDecoder
(orEncoder
) for that type shouldn't require additional allocations.apply
methods onDecoder
orEncoder
.Codec
instances for standard library and circe types in theCodec
companion object and haveEncoder
andDecoder
instances available with no imports.Only the first two are hard requirements, and the third and fourth are probably incompatible.
The text was updated successfully, but these errors were encountered: