scaledn icon indicating copy to clipboard operation
scaledn copied to clipboard

parseEDN - could not find implicit value for parameter r: play.api.data.mapping.RuleLike[scaledn.EDN,Person]

Open fooblahblah opened this issue 9 years ago • 1 comments

I've been following along the README and playing around in the REPL. I've gotten hung up trying to get the "Runtime validation of EDN to Scala" section to work for the case class examples.

For instance when I try to validate the Person case class I get the following:

scala> parseEDN("""{"name" "toto", "age" 34, "addr" {"street" "chboing", "cp" {"cp" 75009}}}""").map(
     |   validateEDN[Person]
     | )
<console>:47: error: could not find implicit value for parameter r: play.api.data.mapping.RuleLike[scaledn.EDN,Person]
  validateEDN[Person]

It seems like I need to define the imlicit RuleLike eh? Can you show an example of a RuleLike for the case classes in the example?

Or am I just missing an import or something?

Thanks

fooblahblah avatar Jul 03 '15 22:07 fooblahblah

A little more info. In the sbt console I get some interesting behavior. If my case class has a second parameter of type Int I get the WriteLike implicit error. Removing it seems to succeed.

Note: Our project already uses shapeless 2.2.3, but I've reverted and tried shapeless 2.1.0 with the same results. The snapshot build of shapeless the project depended on at version "1.0.0-e8180d08620a607ec47613f8c2585f7784e86625" no longer seems to exist.

Any help would be appreciated.

Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import shapeless._
import shapeless._

scala> import scaledn._
import scaledn._

scala> import write._
import write._

scala> import macros._
import macros._

scala> import validate._
import validate._

scala> case class Person(name: String, age: Int)
defined class Person

scala> println(toEDNString(Person("Jeff", 42)))
<console>:25: error: could not find implicit value for parameter w: play.api.data.mapping.WriteLike[Person,String]
              println(toEDNString(Person("Jeff", 42)))
                                 ^

scala> case class Person(name: String)
defined class Person

scala> println(toEDNString(Person("Jeff")))
{"name" "Jeff"}

fooblahblah avatar Jul 07 '15 16:07 fooblahblah