]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/Twitter/User.hs
API bump for HaXml >= 1.22.
[dead/halcyon.git] / src / Twitter / User.hs
1 -- | Functions and data for working with Twitter users.
2 module Twitter.User
3 where
4
5 import Text.XML.HaXml
6
7 import Twitter.Xml
8
9 -- |Represents a Twitter user, and contains the only attribute thereof
10 -- that we care about: the screen (user) name.
11 data User = User { screen_name :: String }
12 deriving (Show, Eq)
13
14
15 -- |Create a 'User' from HaXML 'Content'.
16 user_from_content :: Content i -> (Maybe User)
17 user_from_content c =
18 if (length names) == 0
19 then
20 Nothing
21 else
22 case (get_char_data (names !! 0)) of
23 Nothing -> Nothing
24 (Just content) -> Just (User (content))
25
26 where
27 names = user_screen_name c
28
29
30 -- |Get the URL for the given screen name's timeline.
31 screen_name_to_timeline_url :: String -> String
32 screen_name_to_timeline_url sn =
33 "http://twitter.com/" ++ sn