argonaut-shapeless
argonaut-shapeless copied to clipboard
Encoding `shapeless.nat._2` to `{}`?
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 = {}
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.
Would a PR for encoding and decoding Nat's be welcome in this library?
@kevinmeredith Sure!