lucidsoftware/xtract

Value and is not a member of com.lucidchart.open.xtract.XmlReader

Closed this issue · 4 comments

First, thanks for the library. Seems to be amazing.

Issue

I made all imports, including Play's functional package, but the following error appears to compile:
value and is not a member of com.lucidchart.open.xtract.XmlReader[...].

For example:

import com.lucidchart.open.xtract.{XmlReader, __}
import com.lucidchart.open.xtract.XmlReader._
import play.api.libs.functional.syntax._

case class Foo(a: String, b: Int)

object Foo {
  implicit val reader: XmlReader[Foo] = (
    (__ \ "a").read[String] and // this is the 'and' which the compiler claims
    (__ \ "b").read[Int]
  )(apply _)
}

Can anyone help me? Do I misunderstand something?

Environment

  • Scala: 2.12
  • Play: 2.6
  • OS: macOS mojave

What version of xtract are you using?

@tmccombs ,

"com.lucidchart" %% "xtract" % "2.0.0"

Ah, yeah. So version 2.0 changed the syntax a little bit, and moved from play-syntax to cats. In version two your example would be:

import com.lucidchart.open.xtract.{XmlReader, __}
import com.lucidchart.open.xtract.XmlReader._
import cats.syntax.all._

case class Foo(a: String, b: Int)

object Foo {
  implicit val reader: XmlReader[Foo] = (
    (__ \ "a").read[String], 
    (__ \ "b").read[Int]
  ).mapN(apply _)
}

See https://github.com/lucidsoftware/xtract/blob/master/CHANGELOG.md

Great! Thank you @tmccombs.

I was following the tutorials and articles on the internet and they show in the old way.