[Haskell-cafe] trying to use Tag Soup - fromAttrib

Michael Litchard michael at schmong.org
Tue Nov 2 18:04:18 EDT 2010

Ah thank you. I can go ahead and figure out how to parse that string.
Using a regex is tempting but I have a feeling I can get something
more maintainable if I use another approach.

On Tue, Nov 2, 2010 at 2:52 PM, Daniel Schoepe
<daniel.schoepe at googlemail.com> wrote:
> 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.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list