]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/Twitter/User.hs
a1eed3a356dd5922349d02aa29ad71d3e94a51b3
[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 Control.Applicative ((<$>))
6 import Data.Aeson ((.:), FromJSON(..), Value(Object))
7 import Data.Text (pack)
8 import Data.Monoid (mempty)
9
10 -- | Represents a Twitter user, and contains the only attribute
11 -- thereof that we care about: the screen (user) name.
12 data User = User { screen_name :: String } deriving (Eq, Show)
13
14 instance FromJSON User where
15 parseJSON (Object u) =
16 User <$> (u .: screen_name_field)
17 where
18 screen_name_field = pack "screen_name"
19
20 -- Do whatever.
21 parseJSON _ = mempty
22
23 -- |Get the URL for the given screen name's timeline.
24 screen_name_to_timeline_url :: String -> String
25 screen_name_to_timeline_url =
26 ("http://twitter.com/" ++)