title: Chaining transformations in AntiXML
body: <p>I have anti-xml Elem, something like this (auto-generated data):</p>
  
  <pre><code>&lt;library&gt;
    &lt;bookshelf number="0"&gt;
      &lt;book year="1997" title="Puzzled Coordinators" author="Lily Williams"&gt;&lt;/book&gt;
      &lt;book year="2005" title="Jittery Fare" author="Lucy Taylor"&gt;&lt;/book&gt;
      &lt;book year="2001" title="Dizzy Jurisdiction" author="Lucy Robinson"&gt;&lt;/book&gt;
    &lt;/bookshelf&gt;
    &lt;bookshelf number="1"&gt;
      &lt;book year="1997" title="Bashful Trusts" author="Lucas Wilson"&gt;&lt;/book&gt;
      &lt;book year="2003" title="Outrageous Consequences" author="Byron White"&gt;&lt;/book&gt;
      &lt;book year="1992" title="Irritated Accusations" author="Anne Roberts"&gt;&lt;/book&gt;
    &lt;/bookshelf&gt;
  &lt;/library&gt;
  </code></pre>
  
  <p>And I want to apply several transformations to it, for example:</p>
  
  <pre><code>val transforms: Seq[...] = ...
  val result = transforms.foldLeft(library)(l,t) =&gt; t(l))
  </code></pre>
  
  <p>But I got only as far as this solution:</p>
  
  <pre><code>val transforms: Seq[Elem =&gt; Zipper[Node]] = Seq(
    x =&gt; x \\ "book" filter (_.attrs("year").toInt &gt; 2000) unselect,
    x =&gt; x \\ "book" filter (_.attrs("title").contains("J")) unselect
  )
  val result = transforms.foldLeft(lib)((l,t) =&gt; t(l).head.asInstanceOf[Elem])
  </code></pre>
  
  <p>Is there some way to get better types for transformations (Elem => Elem) and avoid those ugly casts?</p>