Documentation example is not compiling (ADT, ShapesDerivation)
See original GitHub issueHello! I am trying to compile the following example. https://circe.github.io/circe/codecs/adt.html
sealed trait Event
case class Foo(i: Int) extends Event
case class Bar(s: String) extends Event
case class Baz(c: Char) extends Event
case class Qux(values: List[String]) extends Event
Precisely I want to use ShapesDerivation
, like here:
import io.circe._ // no such line in example, but had to import it
object ShapesDerivation {
import io.circe.shapes // not used actually
import shapeless.{ Coproduct, Generic }
implicit def encodeAdtNoDiscr[A, Repr <: Coproduct](implicit
gen: Generic.Aux[A, Repr],
encodeRepr: Encoder[Repr]
): Encoder[A] = encodeRepr.contramap(gen.to)
implicit def decodeAdtNoDiscr[A, Repr <: Coproduct](implicit
gen: Generic.Aux[A, Repr],
decodeRepr: Decoder[Repr]
): Decoder[A] = decodeRepr.map(gen.from)
}
Didn’t use or write previous GenericDerivation
, so no really need to suppress imports?
And this example
import ShapesDerivation._
import io.circe.parser.decode, io.circe.syntax._
decode[Event]("""{ "i": 1000 }""")
(Foo(100): Event).asJson.noSpaces
Doesn’t compile on line decode[Event]("""{ "i": 1000 }""")
, gives two errors:
could not find implicit value for evidence parameter of type io.circe.Decoder[com.example.Event]
and
could not find implicit value for parameter encoder: io.circe.Encoder[com.example.Event]
What else do I need? 🤔 Or may be documentation is a bit out of date?
Version if all libraries I use is 0.11.1.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Scala - Ignore case class field when decoding JSON
I'm playing with the example ADT in ...
Read more >ADT® Troubleshooting FAQs | How to Fix Your Issue
Having trouble with a smoke detector going off or resetting an alarm panel? Troubleshoot issues with these ADT frequently asked questions.
Read more >Command and Control Home Security | Help & FAQs - ADT
Get help with your ADT Command touchscreen panel and the ADT Control App with these frequently asked questions. Visit ADT.com/help for more.
Read more >User Guide - ADT
Smoke detectors also may not sense a fire on another level of a residence or building. A second-floor detector, for example, may not...
Read more >What if my system is not working properly? - ADT
You can refer to your system owner's manual for system specific help or search the MyADT Help Center for answers to common troubleshooting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s the minimization that works as expected:
@travisbrown I’ll put together some gists and post here. Thanks again.