packages feed

clit 0.2.2.2 → 0.2.2.3

raw patch · 2 files changed

+16/−14 lines, 2 filesdep ~clit

Dependency ranges changed: clit

Files

clit.cabal view
@@ -1,5 +1,5 @@ name: clit-version: 0.2.2.2+version: 0.2.2.3 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -46,7 +46,7 @@     main-is: Main.hs     build-depends:         base >=4.9.1.0 && <4.10,-        clit >=0.2.2.2 && <0.3+        clit >=0.2.2.3 && <0.3     default-language: Haskell2010     hs-source-dirs: app     ghc-options: -threaded -rtsopts -with-rtsopts=-N
src/Web/Tweet.hs view
@@ -55,25 +55,27 @@ thread contents hs idNum num filepath = do     let handleStr = concatMap (((++) " ") . ((++) "@")) hs     let content = (take num) . (chunksOf (140-(length handleStr))) $ contents-    case content of-        [] -> pure ()-        [x] -> void $ basicTweet x filepath-        (x:xs) -> do-            firstId <- basicTweet x filepath-            thread' xs hs (Just firstId) num filepath+    case idNum of+        (Just i) -> thread' content hs idNum num filepath+        Nothing -> case content of+            [] -> pure ()+            [x] -> void $ basicTweet x filepath+            (x:xs) -> do+                firstId <- basicTweet x filepath+                thread' xs hs (Just firstId) num filepath  -- | Helper function to make `thread` easier to write.  thread' :: [String] -> [String] -> Maybe Int -> Int -> FilePath -> IO () thread' content hs idNum num filepath = do-    let f = (\str i -> (flip tweetData filepath) (Tweet { _status = str, _trimUser = True, _handles = hs, _replyID = if i == 0 then Nothing else Just i }))-    let initial = f (content !! 0)-    void $ foldr ((>=>) . f) initial (drop 1 content) $ maybe 0 id idNum+    let f = \str i -> (flip tweetData filepath) (Tweet { _status = str, _trimUser = True, _handles = hs, _replyID = if i == 0 then Nothing else Just i })+    let initial = f (head content)+    void $ foldr ((>=>) . f) initial (drop 1 content) $ fromMaybe 0 idNum  -- | Reply with a single tweet. Works the same as `thread` but doesn't take the fourth argument. -- -- > reply "Idk what that means" ["friend1"] (Just 189943500) ".cred" reply :: String -> [String] -> Maybe Int -> FilePath -> IO ()-reply contents hs idNum filepath = thread contents hs idNum 1 filepath+reply contents hs idNum = thread contents hs idNum 1  -- | Tweet a string given a path to credentials; return the id of the status. --@@ -83,7 +85,7 @@  -- | Make a `Tweet` with only the contents. mkTweet :: String -> Tweet-mkTweet contents = over (status) (const (contents)) $ def +mkTweet contents = over (status) (const (contents)) def   -- | tweet, given a `Tweet` and path to credentials. Return id of posted tweet. tweetData :: Tweet -> FilePath -> IO Int@@ -111,7 +113,7 @@                          , (if isJust (_replyID tweet) then "&in_reply_to_status_id=" else "")                          , reply ]     where trim  = _trimUser tweet-          reply = maybe "" id (fmap show $ _replyID $ tweet)+          reply = fromMaybe "" (show <$> _replyID tweet)  -- | Percent-ncode the status update so it's fit for a URL tweetEncode :: Tweet -> BS.ByteString