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

Encoding shapeless.nat._2 to {}? #94

Open
kevinmeredith opened this issue Jun 27, 2017 · 3 comments
Open

Encoding shapeless.nat._2 to {}? #94

kevinmeredith opened this issue Jun 27, 2017 · 3 comments

Comments

@kevinmeredith
Copy link

Why does _2.asJson return {} rather than JNumber(2)?

scala> import argonaut._, Argonaut._, ArgonautShapeless._; import shapeless.nat._2
import argonaut._
import Argonaut._
import ArgonautShapeless._
import shapeless.nat._2

scala> (_2).asJson
res11: argonaut.Json = {}
@alexarchambault
Copy link
Owner

It seems that's because shapeless.Succ is a case class, so a shapeless.Generic is found for it, with HNil as generic representation.

I guess better and higher priority codecs could be added for Nats in argonaut-shapeless.

Although the fact that Nats have a Generic is a problem too IMO... This could be addressed directly in shapeless, by preventing the Generic derivation for them.

@kevinmeredith
Copy link
Author

Would a PR for encoding and decoding Nat's be welcome in this library?

@alexarchambault
Copy link
Owner

@kevinmeredith Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants