Excerpts from Michael Litchard's message of Tue Nov 02 22:40:27 +0100 2010:
> Daniel,
>            Thank you for your reply. I'm still confused.
> When I see a code sample like this
> main = do
>   posts <- liftM parseTags (readFile "posts.xml")
>   print $ head $ map (fromAttrib "Id") $
>                  filter (~== ("<row OwnerUserId=" ++ userid ++ ">"))
>                  posts
> 
> I have no idea how to match that up with what you said. The usage of
> fromAttrib here doesn't match up with what I htink the type signature
> is saying.
> 
> fromAttrib :: (Show str, Eq str, StringLike str) => str -> Tag str -> str
> 
> seems to say "fromAttrib takes two parameters (I know it doesn't
> literally take two), one str (with the constraints in parenthesis to
> the left) and one str of type Tag, giving back a str. Then I look at
> the above code sample and can't match the two up.

In the code sample, the first argument is "Id", in which case the
concrete type for the type variable str is String, and the second
argument are the tags returned by the call to filter, which have type
Tag String.

The second parameter is not a str of type Tag, but Tag (which is a
type constructor) applied to
the same concrete type for str its first argument has.

So in your case, calling
> fromAttrib "href" (TagOpen ...)

Would give you
"/launchWebForward.do?resourceId=4&policy=0&returnTo=%2FshowWebForwards.do". To
get the resourceId you want, you'd have to dissect this string further.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to