]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/Twitter/User.hs
Rewrite CommandLine to use cmdargs and integrate the command-line and RC file options.
[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 )
6 where
7
8 import Control.Applicative ((<$>))
9 import Data.Aeson ((.:), FromJSON(..), Value(Object))
10 import Data.Text (pack)
11 import Data.Monoid (mempty)
12
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)
16
17 instance FromJSON User where
18 parseJSON (Object u) =
19 User <$> (u .: screen_name_field)
20 where
21 screen_name_field = pack "screen_name"
22
23 -- Do whatever.
24 parseJSON _ = mempty
25
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/" ++)