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