我花了很多时间试图弄清楚如何使用HXT。我经常遇到使用deep的例子。deep是做什么的?
例如,this code具有以下特性:
atTag tag = deep (isElem >>> hasName tag)Another example:
-- case-insensitive tag matching
atTagCase tag = deep (isElem >>> hasNameWith ((== tag') . upper . localPart))
where tag' = upper tag
upper = map toUpper发布于 2010-10-10 15:07:58
http://hackage.haskell.org/packages/archive/hxt/latest/doc/html/Control-Arrow-ArrowTree.html#v:deep
树深::
t => a (t b) c -> a (t b) cSource
递归地在整个树中搜索谓词所对应的子树。搜索是自上而下执行的。当找到一个树时,它将成为结果列表的一个元素。不会进一步检查找到的树是否有任何子节点,对于这些子节点,谓词也可以成立。有关这类搜索的信息,请参见multi。
示例:deep isHtmlTable选择文档中的所有顶级表格元素(具有适当的isHtmlTable定义),但表格单元格中不出现表格。
您可以在给定函数名称或带有Hoogle或Hayoo!的类型签名的文档中找到
基本上,如果XML树类似于
<p>
<strong id="a">
<em id="b">
<strong id="c">
foo
</strong>
</em>
</strong>
<ins id="d">
<strong id="e">
bar
</strong>
<em id="f">
baz
</em>
</ins>
</p>deep (isElem >>> hasName "strong") tree将返回以下内容的列表
<strong id="a">
<strong id="e">因为我们可以在进入树时找到这两个<strong>,而(isElem >>> hasName tag) tree将返回一个空列表,因为树的根是<p>,而不是<strong>
https://stackoverflow.com/questions/3899365
复制相似问题