reddit 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+13/−8 lines, 3 filesdep ~aesondep ~api-builderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, api-builder
API changes (from Hackage documentation)
Files
- README.md +1/−1
- reddit.cabal +2/−2
- src/Reddit/Routes/Run.hs +10/−5
README.md view
@@ -1,4 +1,4 @@-reddit for haskell [](https://travis-ci.org/intolerable/reddit)+reddit for haskell [](https://travis-ci.org/intolerable/reddit) --- A Haskell library for interacting with the [Reddit API](http://reddit.com/api).
reddit.cabal view
@@ -1,5 +1,5 @@ name: reddit-version: 0.1.0.0+version: 0.1.1.0 synopsis: Library for interfacing with Reddit's API description: A library for interfacing with Reddit's API in Haskell. Handles@@ -90,7 +90,7 @@ build-depends: base >= 4.6 && < 4.9, aeson,- api-builder >= 0.9,+ api-builder >= 0.9 && < 0.10, bytestring, data-default, http-conduit,
src/Reddit/Routes/Run.hs view
@@ -4,6 +4,7 @@ import Reddit.Types.Error import Reddit.Types.Reddit +import Control.Applicative import Control.Concurrent (threadDelay) import Control.Concurrent.STM import Control.Monad (liftM, when)@@ -16,6 +17,7 @@ import Network.API.Builder.Routes (Route) import Network.HTTP.Conduit import Network.HTTP.Types+import Prelude import qualified Network.API.Builder as API runRoute :: (MonadIO m, FromJSON a) => Route -> RedditT m a@@ -42,11 +44,14 @@ runRouteWithLimiting route Left x -> RedditT $ ExceptT $ return $ Left x Right x -> do- updateRateLimitInfo $ responseHeaders x- decodeFromResponse x--decodeFromResponse :: (Monad m, FromJSON a) => Response ByteString -> RedditT m a-decodeFromResponse = RedditT . ExceptT . return . fmap API.unwrapJSON . API.receive+ case API.unwrapJSON <$> API.receive x of+ Left (API.APIError (RateLimitError resetIn _)) -> do+ updateFromZero resetIn+ runRouteWithLimiting route+ Left y -> RedditT $ ExceptT $ return $ Left y+ Right y -> do+ updateRateLimitInfo $ responseHeaders x+ return y updateRateLimitInfo :: MonadIO m => ResponseHeaders -> RedditT m () updateRateLimitInfo hs = do