]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/Twitter/User.hs
Clean up imports.
[dead/halcyon.git] / src / Twitter / User.hs
1 -- | Functions and data for working with Twitter users.
2 module Twitter.User (
3 User(..),
4 screen_name_to_timeline_url )
5 where
6
7 import Control.Applicative ( (<$>) )
8 import Data.Aeson ( (.:), FromJSON(..), Value(Object) )
9 import Data.Text ( pack )
10 import Data.Monoid ( mempty )
11
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)
15
16 instance FromJSON User where
17 parseJSON (Object u) =
18 User <$> (u .: screen_name_field)
19 where
20 screen_name_field = pack "screen_name"
21
22 -- Do whatever.
23 parseJSON _ = mempty
24
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/" ++)