8000 XML: extraction from nested structures with customized behavior · Issue #267 · propensive/rapture · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on May 21, 2018. It is now read-only.
This repository was archived by the owner on May 21, 2018. It is now read-only.
XML: extraction from nested structures with customized behavior #267
Open
@juanjovazquez

Description

@juanjovazquez

Xml module is not able to dispatch a valid Extractor from nested structures when the extraction of some middle elements has been customized. The behavior has been observed starting from nested structures greater than three elements. See the next code snippet as an example of this issue:

object RaptureXmlOk {
  import rapture.xml._

  case class Foo(bar: Bar)
  case class Bar(baz: Baz)
  case class Baz(qux: Qux)
  case class Qux(value: String)

  implicitly[Extractor[Bar, Xml]] // works
  implicitly[Extractor[Foo, Xml]] // works
}

// REPL
// :paste
// Entering paste mode (ctrl-D to finish)
// CTRL +D
// Exiting paste mode, now interpreting.
// defined object RaptureXmlOk

object RaptureXmlKo {
  import rapture.xml._, xmlBackends.stdlib._

  case class Foo(bar: Bar)
  case class Bar(baz: Baz)
  case class Baz(qux: Qux)
  object Baz {
    // custom extractor in order to be able to extract this:
    // xml"""<foo><bar><baz><value>xxx</value></baz></bar></foo>""".as[Foo]
    // i.e. without the extra <qux>...</qux>
    implicit val bazExtractor: Extractor[Baz, Xml] =
      Xml.extractor[Qux].map(Baz(_))
  }
  case class Qux(value: String)

  implicitly[Extractor[Bar, Xml]] // works
  implicitly[Extractor[Foo, Xml]] // fails!!!
}

// REPL
// :paste
// Entering paste mode (ctrl-D to finish)
// CTRL +D
// Exiting paste mode, now interpreting.
// <console>:27: error: cannot extract type RaptureXmlKo.Foo from rapture.xml.Xml.
//  implicitly[Extractor[Foo, Xml]] // fails!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0