Custom encoders/decoders example failing with Scala 2.11.x
See original GitHub issueThe example from the documentation fails on Scala 2.11.11, but I can run it successfully on Scala 2.12.x
scala> class Thing(val foo: String, val bar: Int)
defined class Thing
scala> implicit val encodeFoo: Encoder[Thing] = new Encoder[Thing] {
| final def apply(a: Thing): Json = Json.obj(
| ("foo", Json.fromString(a.foo)),
| ("bar", Json.fromInt(a.bar))
| )
| }
encodeFoo: io.circe.Encoder[Thing] = $anon$1@bfe134d
scala> implicit val decodeFoo: Decoder[Thing] = new Decoder[Thing] {
| final def apply(c: HCursor): Decoder.Result[Thing] =
| for {
| foo <- c.downField("foo").as[String]
| bar <- c.downField("bar").as[Int]
| } yield {
| new Thing(foo, bar)
| }
| }
<console>:17: error: value flatMap is not a member of io.circe.Decoder.Result[String]
foo <- c.downField("foo").as[String]
^
<console>:18: error: value map is not a member of io.circe.Decoder.Result[Int]
bar <- c.downField("bar").as[Int]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Scala 2.11.0 - The Scala Programming Language
Use Scastie to run single-file Scala programs in your browser using multiple Scala compilers; the production Scala 2.x compilers, Scala.js, Dotty, and Typelevel ......
Read more >How do I change intellij idea to compile with scala 2.11?
In IntelliJ 2016.x you upgrade Scala by. Ensure Scala Plugin up to date. Then by going to: File | Other Settings | Default...
Read more >circe/circe - Gitter
... date: Option[java.sql.Date]). I am guessing I have to write a custom encoder/ decoder for it. Can some show a sample how to...
Read more >Installation · Scalafix - Scala Center
Every pull request is tested on both Linux and Windows. Java 8 or Java 11. Scala 2.11, 2.12 or 2.13. Scala 3.x: Scala...
Read more >The Scala Plugin - Gradle User Manual
Just like the Java plugin, the Scala plugin allows you to configure custom locations for Scala production and test source files. Example 2....
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
To overcome this issue you can use cats either, simply import it:
import cats.syntax.either._
@djvulee This has slipped through the cracks, but a PR would be very welcome.