2021年3月22日星期一

Using local bindings in arrow notation with HXT

I am trying to parse an XML file with hxt. In the code below, I need to parse the inner elements with an extra parameter obtained from an attribute in the outer tag. But i is not available in the second line (second arrow?). How can I pass i to the getTerminal?

getSentence = atTag "s" >>>    proc x -> do      i   <- getAttrValue "id" -< x      ts  <- listA (getTerminal i) <<< atTag "terminals"    -< x      returnA -< Sentence { sid = i, terminals = ts }    ...    getTerminal sid = atTag "t" >>>     proc x -> do      i   <- getAttrValue "id"    -< x          lem <- getAttrValue "lemma" -< x      returnA -< Terminal { lemma = lem, tid = nid i }    where      nid x = fromMaybe x (stripPrefix (sid ++ "_") x)  

That is, i contains the value that I would like to pass to getTerminal.

https://stackoverflow.com/questions/66756351/using-local-bindings-in-arrow-notation-with-hxt March 23, 2021 at 10:15AM

没有评论:

发表评论