packages feed

tweet-hs 1.0.1.41 → 1.0.1.42

raw patch · 7 files changed

+40/−52 lines, 7 filesdep ~htoml-megaparsecdep ~megaparsecsetup-changedPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: htoml-megaparsec, megaparsec

API changes (from Hackage documentation)

- Web.Tweet: showTweets :: Bool -> Either (ParseError Char Void) Timeline -> String
+ Web.Tweet: showTweets :: Bool -> Either (ParseErrorBundle String Void) Timeline -> String
- Web.Tweet.API: deleteTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: deleteTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: deleteTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: deleteTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: favoriteTweetList :: String -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: favoriteTweetList :: String -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: favoriteTweetListMem :: String -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: favoriteTweetListMem :: String -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: favoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: favoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: getFavorites :: Int -> String -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: getFavorites :: Int -> String -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: getProfile :: String -> Int -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: getProfile :: String -> Int -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: getProfileMax :: String -> Int -> FilePath -> Maybe Int -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: getProfileMax :: String -> Int -> FilePath -> Maybe Int -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: getProfileMaxMem :: String -> Int -> Config -> Maybe Int -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: getProfileMaxMem :: String -> Int -> Config -> Maybe Int -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: getTimeline :: Int -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: getTimeline :: Int -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: getTimelineMem :: Int -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: getTimelineMem :: Int -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: mentions :: Int -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: mentions :: Int -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: mentionsMem :: Int -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: mentionsMem :: Int -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: retweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: retweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: retweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: retweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: unfavoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: unfavoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: unfavoriteTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: unfavoriteTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: unretweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: unretweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.API: unretweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)
+ Web.Tweet.API: unretweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline)
- Web.Tweet.Utils: getTweets :: ByteString -> Either (ParseError Char Void) Timeline
+ Web.Tweet.Utils: getTweets :: ByteString -> Either (ParseErrorBundle String Void) Timeline

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# tweet-hs++## 1.0.1.42++  * Update for new `megaparsec`
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
src/Web/Tweet/API.hs view
@@ -51,11 +51,11 @@     pure . view tweetId . head . either (error "failed to parse tweet") id . getTweets . BSL.toStrict $ bytes  -- | Gets user profile with max_id set.-getProfileMax :: String -> Int -> FilePath -> Maybe Int -> IO (Either (ParseError Char Void) Timeline)+getProfileMax :: String -> Int -> FilePath -> Maybe Int -> IO (Either (ParseErrorBundle String Void) Timeline) getProfileMax = fmap (getTweets . BSL.toStrict) .*** getProfileRaw  -- | Gets user profile with max_id set.-getProfileMaxMem :: String -> Int -> Config -> Maybe Int -> IO (Either (ParseError Char Void) Timeline)+getProfileMaxMem :: String -> Int -> Config -> Maybe Int -> IO (Either (ParseErrorBundle String Void) Timeline) getProfileMaxMem = fmap (getTweets . BSL.toStrict) .*** getProfileRawMem  -- | Gets user profile with max_id set.@@ -73,11 +73,11 @@         Nothing -> "?screen_name=" ++ sn ++ "&count=" ++ show count }  -- | Get mentions and parse response as a list of tweets-mentions :: Int -> FilePath -> IO (Either (ParseError Char Void) Timeline)+mentions :: Int -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) mentions = fmap (getTweets . BSL.toStrict) .* mentionsRaw  -- | Get mentions and parse response as a list of tweets-mentionsMem :: Int -> Config -> IO (Either (ParseError Char Void) Timeline)+mentionsMem :: Int -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) mentionsMem = fmap (getTweets . BSL.toStrict) .* mentionsRawMem  -- | Gets mentions@@ -91,7 +91,7 @@     where requestString = "?count=" ++ show count  -- | Get user profile given screen name and how many tweets to return-getProfile :: String -> Int -> FilePath -> IO (Either (ParseError Char Void) Timeline)+getProfile :: String -> Int -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) getProfile sn count filepath = getProfileMax sn count filepath Nothing  -- | Mute a user given their screen name@@ -132,15 +132,15 @@     where requestString = "?count=" ++ show count  -- | Get a user's favorites-getFavorites :: Int -> String -> FilePath -> IO (Either (ParseError Char Void) Timeline)+getFavorites :: Int -> String -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) getFavorites count = fmap (fmap (take count) . getTweets . BSL.toStrict) .* favoriteTweetListRaw  -- | Get a timeline-getTimeline :: Int -> FilePath -> IO (Either (ParseError Char Void) Timeline)+getTimeline :: Int -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) getTimeline = fmap (getTweets . BSL.toStrict) .* getTimelineRaw  -- | Get a timeline-getTimelineMem :: Int -> Config -> IO (Either (ParseError Char Void) Timeline)+getTimelineMem :: Int -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) getTimelineMem = fmap (getTweets . BSL.toStrict) .* getTimelineRawMem  -- | Get a user's timeline and return response as a bytestring@@ -162,11 +162,11 @@ deleteTweetMem = fmap void . deleteTweetRawMem  -- | Get response, i.e. the tweet deleted-deleteTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)+deleteTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) deleteTweetResponse = fmap (getTweets . BSL.toStrict) .* deleteTweetRaw  -- | Get response, i.e. the tweet deleted-deleteTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)+deleteTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) deleteTweetResponseMem = fmap (getTweets . BSL.toStrict) .* deleteTweetRawMem  -- | Favorite a tweet given its id@@ -178,15 +178,15 @@ favoriteTweetMem = fmap void . favoriteTweetRawMem  -- | Favorite a tweet and returned the (parsed) response-favoriteTweetList :: String -> FilePath -> IO (Either (ParseError Char Void) Timeline)+favoriteTweetList :: String -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) favoriteTweetList = fmap (getTweets . BSL.toStrict) .* favoriteTweetListRaw  -- | Favorite a tweet and returned the (parsed) response-favoriteTweetListMem :: String -> Config -> IO (Either (ParseError Char Void) Timeline)+favoriteTweetListMem :: String -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) favoriteTweetListMem = fmap (getTweets . BSL.toStrict) .* favoriteTweetListRawMem  -- | Favorite a tweet and returned the (parsed) response-favoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)+favoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) favoriteTweetResponse = fmap (getTweets . BSL.toStrict) .* favoriteTweetRaw  -- | Unfavorite a tweet given its id@@ -198,11 +198,11 @@ unfavoriteTweetMem = fmap void . unfavoriteTweetRawMem  -- | Unfavorite a tweet and returned the (parsed) response-unfavoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)+unfavoriteTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) unfavoriteTweetResponse = fmap (getTweets . BSL.toStrict) .* unfavoriteTweetRaw  -- | Unfavorite a tweet and returned the (parsed) response-unfavoriteTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)+unfavoriteTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) unfavoriteTweetResponseMem = fmap (getTweets . BSL.toStrict) .* unfavoriteTweetRawMem  -- | Unretweet a tweet given its id@@ -214,11 +214,11 @@ unretweetTweetMem = fmap void . unretweetTweetRawMem  -- | Unretweet a tweet and returned the (parsed) response-unretweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)+unretweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) unretweetTweetResponse = fmap (getTweets . BSL.toStrict) .* unretweetTweetRaw  -- | Unretweet a tweet and returned the (parsed) response-unretweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)+unretweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) unretweetTweetResponseMem = fmap (getTweets . BSL.toStrict) .* unretweetTweetRawMem  -- | Unfollow a user given their screen name@@ -262,11 +262,11 @@ retweetTweetMem = fmap void . retweetTweetRawMem  -- | Retweet a tweet and returned the (parsed) response-retweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseError Char Void) Timeline)+retweetTweetResponse :: Integer -> FilePath -> IO (Either (ParseErrorBundle String Void) Timeline) retweetTweetResponse = fmap (getTweets . BSL.toStrict) .* retweetTweetRaw  -- | Retweet a tweet and returned the (parsed) response-retweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseError Char Void) Timeline)+retweetTweetResponseMem :: Integer -> Config -> IO (Either (ParseErrorBundle String Void) Timeline) retweetTweetResponseMem = fmap (getTweets . BSL.toStrict) .* retweetTweetRawMem  -- | Get a lisr of favorited tweets by screen name; return bytestring response
src/Web/Tweet/API/Internal.hs view
@@ -30,7 +30,7 @@ showFilteredTL filters sn count color = fmap (showTweets color . fmap (foldr (.) id filters)) . getProfile sn count  -- | Display user timeline in color, as appropriate-showTweets :: Bool -> Either (ParseError Char Void) Timeline -> String+showTweets :: Bool -> Either (ParseErrorBundle String Void) Timeline -> String showTweets color = either show id . fmap (if color then displayTimelineColor else displayTimeline)  -- | Display a user's favorites
src/Web/Tweet/Parser.hs view
@@ -59,43 +59,27 @@  -- | Skip a set of square brackets [] skipInsideBrackets :: Parser ()-skipInsideBrackets = void (between (char '[') (char ']') $ many (skipInsideBrackets <|> void (noneOf ("[]" :: String))))+skipInsideBrackets = void (between (single '[') (single ']') $ many (skipInsideBrackets <|> void (noneOf ("[]" :: String))))  -- | Skip user mentions field to avoid parsing the wrong n skipMentions :: Parser () skipMentions = do-    many $ try $ anyChar >> notFollowedBy (string "\"user_mentions\":")+    many $ try $ anySingle >> notFollowedBy (string "\"user_mentions\":")     string ",\"user_mentions\":"     skipInsideBrackets  -- | Throw out input until we get to a relevant tag. filterStr :: String -> Parser String filterStr str = do-    many $ try $ anyChar >> notFollowedBy (string ("\"" <> str <> "\":"))-    char ','+    many $ try $ anySingle >> notFollowedBy (string ("\"" <> str <> "\":"))+    single ','     filterTag str -{--filterList :: Parser [String]-filterList = try $ do-    many $ try $ anyChar >> notFollowedBy (string ("\"withheld_in_countries\":"))-    char ','-    filterWithheld---filterWithheld :: Parser [String]-filterWithheld = do-    string "\"withheld_in_countries\":[\""-    codes <- some $ do { char '\"' ; interior <- many (noneOf ("\"]" :: String)) ; char '\"' ; optional (char ',') ; pure interior }-    char ']'-    pure codes-    -}- -- | Parse a field given its tag filterTag :: String -> Parser String filterTag str = do     string $ "\"" <> str <> "\":"-    open <- optional $ char '\"'+    open <- optional $ single '\"'     let forbidden = if isJust open then ("\\\"" :: String) else ("\\\"," :: String)     many $ parseHTMLChar <|> noneOf forbidden <|> specialChar '\"' <|> specialChar '/' <|> newlineChar <|> emojiChar <|> unicodeChar -- TODO modify parsec to make this parallel? @@ -106,12 +90,12 @@ -- | Parser for unicode; twitter will give us something like "/u320a" unicodeChar :: Parser Char unicodeChar = toEnum . fromIntegral . f <$> go-    where go = string "\\u" >> count 4 anyChar+    where go = string "\\u" >> count 4 anySingle           f = fromHex . filterEmoji . BS.pack . fmap (fromIntegral . fromEnum)   emojiChar :: Parser Char emojiChar = go a-    where a = string "\\ud" >> count 3 anyChar+    where a = string "\\ud" >> count 3 anySingle           go = (<*>) =<< (((T.head . decodeUtf16) .* ((<>) . (<> "d") . ("d" <>))) <$>)  decodeUtf16 :: String -> T.Text@@ -129,9 +113,9 @@ -- | Parse HTML chars parseHTMLChar :: Parser Char parseHTMLChar = do-    char '&'-    innards <- many $ noneOf (";" :: String)-    char ';'+    single '&'+    innards <- many $ anySingleBut ';'+    single ';'     pure . (\case          (Just a) -> a          Nothing -> '?') $ M.lookup innards (M.fromList [("amp",'&'),("gt",'>'),("lt",'<'),("quot",'"'),("euro",'€'),("ndash",'–'),("mdash",'—')])
src/Web/Tweet/Utils.hs view
@@ -48,7 +48,7 @@ filterQuotes = filter ((==Nothing) . view quoted)  -- | Get a list of tweets from a response, returning author, favorites, retweets, and content.-getTweets :: BS2.ByteString -> Either (ParseError Char Void) Timeline+getTweets :: BS2.ByteString -> Either (ParseErrorBundle String Void) Timeline getTweets = parse parseTweet "" . BS.unpack  -- | Get a list of tweets from a response, returning author, favorites, retweets, and content.
tweet-hs.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: tweet-hs-version: 1.0.1.41+version: 1.0.1.42 license: BSD3 license-file: LICENSE copyright: 2016-2018 Vanessa McHale@@ -15,6 +15,7 @@ build-type: Simple extra-source-files:     README.md+    CHANGELOG.md     cabal.project.local     bash/mkCompletions     test/data@@ -68,12 +69,12 @@         http-client -any,         http-types -any,         authenticate-oauth -any,-        megaparsec >=6.0,+        megaparsec >=7.0,         bytestring -any,         split -any,         microlens -any,         unordered-containers -any,-        htoml-megaparsec >=2.0.0.0,+        htoml-megaparsec >=2.1.0.0,         data-default -any,         text -any,         containers -any,