1 -- | Functions and data for working with Twitter users.
5 import Control.Applicative ((<$>))
6 import Data.Aeson ((.:), FromJSON(..), Value(Object))
7 import Data.Text (pack)
8 import Data.Monoid (mempty)
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)
14 instance FromJSON User where
15 parseJSON (Object u) =
16 User <$> (u .: screen_name_field)
18 screen_name_field = pack "screen_name"
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/" ++)