<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Ah, zeroArrow looks exactly like what I
need here!<br>
<br>
Thanks, this helps.<br>
<br>
Mateusz Kowalczyk<br>
<br>
On 01/01/13 01:08, <a class="moz-txt-link-abbreviated" href="mailto:dag.odenhall@gmail.com">dag.odenhall@gmail.com</a> wrote:<br>
</div>
<blockquote
cite="mid:CACsGuknpkD6_i84JfSjXyvccbeeqROLJsp_WyPH4MD-c46Cdtw@mail.gmail.com"
type="cite">
<div dir="ltr">(">>>" is my GHCi prompt, might be a bit
confusing for an arrow example.)<br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Tue, Jan 1, 2013 at 2:05 AM, <a
moz-do-not-send="true" href="mailto:dag.odenhall@gmail.com">dag.odenhall@gmail.com</a>
<span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dag.odenhall@gmail.com" target="_blank">dag.odenhall@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Use arrow notation and zeroArrow, like so:<br>
<br>
</div>
{-# LANGUAGE Arrows #-}<br>
import Text.XML.HXT.Core<br>
getA =<br>
hasName "a" >>> proc elem -> do<br>
text <- getText <<< getChildren
-< elem<br>
if text == "Hello Two!"<br>
then getAttrValue "href" -< elem<br>
else zeroArrow -< ()<br>
<br>
>>> runX $ readString []
"<html><a href='<a
moz-do-not-send="true"
href="http://example.com/somelink.html"
target="_blank">example.com/somelink.html</a>'>Hello
One!</a><a href='<a
moz-do-not-send="true"
href="http://example.com/anotherlink.html"
target="_blank">example.com/anotherlink.html</a>'>Hello
Two!</a></html>" >>> deep
getA<br>
["<a moz-do-not-send="true"
href="http://example.com/anotherlink.html"
target="_blank">example.com/anotherlink.html</a>"]<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Dec 31, 2012 at 3:36
PM, Mateusz Kowalczyk <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:fuuzetsu@fuuzetsu.co.uk"
target="_blank">fuuzetsu@fuuzetsu.co.uk</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
I'm not sure if this is the right place to ask
this but here goes.<br>
<br>
I'm currently working with HXT and I quite like
it. There's one issue I<br>
can't solve (at least now without some dirty,
dirty hacking) and I'm<br>
sure it's fairly simple.<br>
<br>
Consider the following mark-up<br>
<br>
<a href="<a moz-do-not-send="true"
href="http://example.com/somelink.html"
target="_blank">example.com/somelink.html</a>">Hello
One!</a><br>
<a href="<a moz-do-not-send="true"
href="http://example.com/anotherlink.html"
target="_blank">example.com/anotherlink.html</a>">Hello
Two!</a><br>
<br>
Now, what I'm trying to achieve is to get the href
based on the text. I<br>
can test for what the text is by traversing
<a>s, then using the<br>
getChildren >>> getText arrow. What I
can't figure out is how to check<br>
the text and then get the href as by the time I
get to the text, I'll<br>
further down the tree!<br>
<br>
I imagine it would look something along the lines
of<br>
(getChildren >>> getText <?*>
"Hello Two") `guards` getAttrValue<br>
"href". <?*> is just a random operator I
made up for illustration<br>
purposes that works as a predicate over arrows.<br>
<br>
Is this the right approach? Is there a built-in
that already does what I want? It<br>
seems like a common task...<br>
<br>
Mateusz Kowalczyk<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org"
target="_blank">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://www.haskell.org/mailman/listinfo/haskell-cafe"
target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>