2

Upgrading circe from 0.4.1 to 0.7.0 broke the following code:

import shapeless._
import syntax.singleton._
import io.circe.generic.auto._

.run[Record.`'transaction_id -> Int`.T](transport)

def run[A](transport: Json => Future[Json])(implicit decoder: Decoder[A], exec: ExecutionContext): Future[A]

With the following error:

 could not find implicit value for parameter decoder: io.circe.Decoder[shapeless.::[Int with shapeless.labelled.KeyTag[Symbol with shapeless.tag.Tagged[String("transaction_id")],Int],shapeless.HNil]]
[error]       .run[Record.`'transaction_id -> Int`.T](transport)
[error]                                              ^

Am I missing some import here or are these encoders/decoders not available in circe anymore?

simao
  • 14,491
  • 9
  • 55
  • 66

1 Answers1

2

Instances for Shapeless's hlists, records, etc. were moved to a separate circe-shapes module in the circe 0.6.0 release. If you add this module to your build, the following should just work:

import io.circe.jawn.decode, io.circe.shapes._
import shapeless._, record.Record, syntax.singleton._

val doc = """{ "transaction_id": 1 }"""

val res = decode[Record.`'transaction_id -> Int`.T](doc)

The motivation for moving these instances was that the improved generic derivation introduced in 0.6 meant that they were no longer necessary, and keeping them out of implicit scope when they're not needed is both cleaner and potentially supports faster compile times. The new circe-shapes module also includes features that were not available in circe-generic, such as instances for coproducts.

Travis Brown
  • 138,631
  • 12
  • 375
  • 680