djspiewak / anti-xml

The scala.xml library has some very annoying issues. Time for a clean-room replacement!
http://anti-xml.org
Other
169 stars 35 forks source link

Zipper With Empty Context Does Not Define flatMap #13

Closed djspiewak closed 13 years ago

djspiewak commented 13 years ago

When a Zipper is created with an empty context (e.g. via Group#toZipper), the resulting Zipper does not define a working flatMap. If this were just a result of toZipper, then it would be excusable. Unfortunately, this arises when actually using Zipper normally:

val g: Group[Node] = ...
(g \ "foo").unselect flatMap { e => Some(e) }         // => Group(), regardless of what g is

This appears to be a product of the fact that flatMap builds its result by mapping over the zipper context. Since that context is empty after unselect (in this case), the result will always be Group().