Last active
March 5, 2017 12:12
-
-
Save juanjovazquez/6a4a7c4402cddfa978b4ed90f289ef84 to your computer and use it in GitHub Desktop.
Rapture: XML extraction problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment