packages feed

twitter-types 0.2.20140407 → 0.2.20140424

raw patch · 4 files changed

+93/−11 lines, 4 files

Files

.travis.yml view
@@ -1,1 +1,8 @@ language: haskell+before_install:+    - cabal install hpc-coveralls+script:+    - cabal configure --enable-tests --enable-library-coverage && cabal build+    - run-cabal-test+after_script:+    - hpc-coveralls tests
Web/Twitter/Types.hs view
@@ -28,6 +28,8 @@        , URLEntity(..)        , MediaEntity(..)        , MediaSize(..)+       , Place(..)+       , BoundingBox(..)        , checkError        )        where@@ -90,6 +92,7 @@   , statusRetweetCount  :: Maybe Integer   , statusUser          :: User   , statusRetweet       :: Maybe Status+  , statusPlace         :: Maybe Place   } deriving (Show, Eq)  instance FromJSON Status where@@ -106,6 +109,7 @@            <*> o .:? "retweet_count"            <*> o .:  "user"            <*> o .:? "retweeted_status"+           <*> o .:? "place"   parseJSON _ = mzero  data SearchResult body =@@ -388,6 +392,44 @@     MediaSize <$> o .: "w"               <*> o .: "h"               <*> o .: "resize"+  parseJSON _ = mzero++data Place =+  Place+  { placeAttributes   :: HashMap Text Text+  , placeBoundingBox  :: BoundingBox+  , placeCountry      :: Text+  , placeCountryCode  :: Text+  , placeFullName     :: Text+  , placeId           :: Text+  , placeName         :: Text+  , placeType         :: Text+  , placeUrl          :: Text+  } deriving (Show, Eq)++instance FromJSON Place where+  parseJSON (Object o) =+    Place <$> o .: "attributes"+          <*> o .: "bounding_box"+          <*> o .: "country"+          <*> o .: "country_code"+          <*> o .: "full_name"+          <*> o .: "id"+          <*> o .: "name"+          <*> o .: "place_type"+          <*> o .: "url"+  parseJSON _ = mzero++data BoundingBox =+  BoundingBox+  { boundingBoxCoordinates  :: [[[Double]]]+  , boundingBoxType         :: Text+  } deriving (Show, Eq)++instance FromJSON BoundingBox where+  parseJSON (Object o) =+    BoundingBox <$> o .: "coordinates"+                <*> o .: "type"   parseJSON _ = mzero  -- | Entity handling.
Web/Twitter/Types/Lens.hs view
@@ -28,6 +28,8 @@        , URLEntity        , MediaEntity        , MediaSize+       , Place+       , BoundingBox         , statusCreatedAt        , statusId@@ -41,6 +43,7 @@        , statusRetweetCount        , statusRetweet        , statusUser+       , statusPlace         , searchResultStatuses        , searchResultSearchMetadata@@ -132,6 +135,19 @@        , msHeight        , msResize +       , placeAttributes+       , placeBoundingBox+       , placeCountry+       , placeCountryCode+       , placeFullName+       , placeId+       , placeName+       , placeType+       , placeUrl++       , boundingBoxCoordinates+       , boundingBoxType+        , enHashTags        , enUserMentions        , enURLs@@ -175,17 +191,20 @@        , URLEntity        , MediaEntity        , MediaSize+       , Place+       , BoundingBox        ) import Data.Text (Text) import Data.HashMap.Strict (HashMap)  type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t-type Lens' s a = Lens s s a a+type SimpleLens s a = Lens s s a a +#define HASHSIGN # #define SIMPLE_LENS(name, s, a) \-name :: Lens' (s) (a);\+name :: SimpleLens (s) (a);\ name f record = (\newVal -> record { TT.name = newVal }) <$> (f (TT.name record));\-{-# INLINE name #-}+{-HASHSIGN INLINE name HASHSIGN-}  #define TYPECHANGE_LENS(name, s) \ name :: Lens ((s) a) ((s) b) (a) (b);\@@ -203,6 +222,7 @@ SIMPLE_LENS(statusRetweetCount        , Status,  Maybe Integer                ) SIMPLE_LENS(statusRetweet             , Status,  Maybe Status                 ) SIMPLE_LENS(statusUser                , Status,  User                         )+SIMPLE_LENS(statusPlace               , Status,  Maybe Place                  )  TYPECHANGE_LENS(searchResultStatuses  , SearchResult                          ) SIMPLE_LENS(searchResultSearchMetadata, SearchResult body,  SearchMetadata    )@@ -294,6 +314,19 @@ SIMPLE_LENS(msHeight                  , MediaSize,  Int                       ) SIMPLE_LENS(msResize                  , MediaSize,  Text                      ) +SIMPLE_LENS(placeAttributes           , Place,  HashMap Text Text             )+SIMPLE_LENS(placeBoundingBox          , Place,  BoundingBox                   )+SIMPLE_LENS(placeCountry              , Place,  Text                          )+SIMPLE_LENS(placeCountryCode          , Place,  Text                          )+SIMPLE_LENS(placeFullName             , Place,  Text                          )+SIMPLE_LENS(placeId                   , Place,  Text                          )+SIMPLE_LENS(placeName                 , Place,  Text                          )+SIMPLE_LENS(placeType                 , Place,  Text                          )+SIMPLE_LENS(placeUrl                  , Place,  Text                          )++SIMPLE_LENS(boundingBoxCoordinates    , BoundingBox,  [[[Double]]]            )+SIMPLE_LENS(boundingBoxType           , BoundingBox,  Text                    )+ SIMPLE_LENS(enHashTags                , Entities,  [Entity HashTagEntity]     ) SIMPLE_LENS(enUserMentions            , Entities,  [Entity UserEntity]        ) SIMPLE_LENS(enURLs                    , Entities,  [Entity URLEntity]         )@@ -303,10 +336,10 @@ SIMPLE_LENS(entityIndices             , Entity a,  EntityIndices              )  class AsStatus s where-    status_id :: Lens' s StatusId-    text :: Lens' s Text-    user :: Lens' s User-    created_at :: Lens' s DateString+    status_id :: SimpleLens s StatusId+    text :: SimpleLens s Text+    user :: SimpleLens s User+    created_at :: SimpleLens s DateString  instance AsStatus Status where     status_id = statusId@@ -333,9 +366,9 @@     created_at = dmCreatedAt  class AsUser u where-    user_id :: Lens' u UserId-    name :: Lens' u UserName-    screen_name :: Lens' u Text+    user_id :: SimpleLens u UserId+    name :: SimpleLens u UserName+    screen_name :: SimpleLens u Text  instance AsUser User where     user_id = userId
twitter-types.cabal view
@@ -1,5 +1,5 @@ name:              twitter-types-version:           0.2.20140407+version:           0.2.20140424 license:           BSD3 license-file:      LICENSE author:            Takahiro HIMURA