Work with lists in HXT

I'm going crazy trying to use simple functions >>.and >.defined here .

I want to get the length of all text for node in HXT. I use this:

runX (doc //> hasName "div" //> text >>. unlines)

Where docis my arrow XmlTree.

This gives me all the text for all divs (including the text for any children that they have). It gets the text as a string, because I use unlines. Now I want to get the length of this string, so I'm trying:

runX (doc //> hasName "div" //> text >>. unlines >. length)

And HXT seems to magically convert my string back to an array, because I get this:

[0,17,0,20,0,11,...]

I want all of them to Intadd up. How should I do it?

Update

The text function is defined as follows:

text = deep (getChildren >>> getText)

, getChildren, :

text = deep getText

div. div, .

+3
1

:

Prelude Text.XML.HXT.Core> flip runLA undefined $ (constL [1, 2] >>>  arr id) >>. take 1
[1]
Prelude Text.XML.HXT.Core> flip runLA undefined $  constL [1, 2] >>> (arr id  >>. take 1)
[1,2]

. . , .

+2

All Articles