You should almost never have to call a run
-function several times on HXT
arrow to get the result you want. In your case, listA
can be used instead of
map runLA
to get a list of results from an arrow. You can also get rid of
many of the getChildren
calls by using the />
operator.
Your proc
-version of toTuple
looks fine to me, but I'd rewrite the rest of
your example code as
tx1 = runLA (xread /> hasName "list" /> hasName "item" >>> toTuple) xml
toTuple = proc tree -> do
desc <- aDesc -< tree
disp <- aDisp -< tree
plist <- aPlist -< tree
returnA -< (desc, disp, plist)
aDesc = getChildren >>> hasName "desc" /> getText
aDisp = getChildren >>> hasName "display" /> getText
aPlist = getChildren >>> hasName "plist" >>> listA (getChildren /> getText)
And instead of using arrow notation, toTuple
can be written simply as
toTuple = aDesc &&& aDisp &&& aPlist >>> arr3 (,,)