1 -- | Functions and data for working with Twitter users.
4 screen_name_to_timeline_url
8 import Control.Applicative ((<$>))
9 import Data.Aeson ((.:), FromJSON(..), Value(Object))
10 import Data.Text (pack)
11 import Data.Monoid (mempty)
13 -- | Represents a Twitter user, and contains the only attribute
14 -- thereof that we care about: the screen (user) name.
15 data User = User { screen_name :: String } deriving (Eq, Show)
17 instance FromJSON User where
18 parseJSON (Object u) =
19 User <$> (u .: screen_name_field)
21 screen_name_field = pack "screen_name"
26 -- |Get the URL for the given screen name's timeline.
27 screen_name_to_timeline_url :: String -> String
28 screen_name_to_timeline_url =
29 ("http://twitter.com/" ++)