Nice to see a full example buiilt up like this. Just wondering why you could not go "full potato" with automatic derivation given adequate test coverage.
Hah :) Good question. You absolutely can, it's a preference to avoid magic. The additional boilerplate arguably makes it more explicit and avoids having to include imports for auto and syntax at the calling sites. For anyone not sure, to use auto in the video example remove all the semiauto encoders/decoders except for the value class special case 'Summink' which requires custom codecs, and change the lhs test assertion for the decoder to incomingJson.as[Message] and the encoder to msg.asJson. Also need to add imports for io.circe.generic.auto._ and io.circe.syntax._ at the call locations (just the spec file in this case). Thanks for the feedback.
Habit. Practically, there's not really a benefit, it just prevents extending the case class: nrinaudo.github.io/scala-best-practices/tricky_behaviours/final_case_classes.html
Nice to see a full example buiilt up like this.
Just wondering why you could not go "full potato" with automatic derivation given adequate test coverage.
Hah :) Good question. You absolutely can, it's a preference to avoid magic. The additional boilerplate arguably makes it more explicit and avoids having to include imports for auto and syntax at the calling sites.
For anyone not sure, to use auto in the video example remove all the semiauto encoders/decoders except for the value class special case 'Summink' which requires custom codecs, and change the lhs test assertion for the decoder to incomingJson.as[Message] and the encoder to msg.asJson. Also need to add imports for io.circe.generic.auto._ and io.circe.syntax._ at the call locations (just the spec file in this case).
Thanks for the feedback.
@@appliedfunctor I totally get the reasons for semiauto but good to know the tiny type Summink can accommodated in the fully automatic mode.
Why did you use the final case class, can we use the case class itself?
Habit. Practically, there's not really a benefit, it just prevents extending the case class: nrinaudo.github.io/scala-best-practices/tricky_behaviours/final_case_classes.html
@@appliedfunctor Thanks, I will read this