packages feed

playlists-http 0.1.1.0 → 0.2.0.0

raw patch · 3 files changed

+23/−13 lines, 3 filesdep +transformersdep −eitherdep ~playlistsPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

Dependencies removed: either

Dependency ranges changed: playlists

API changes (from Hackage documentation)

- Text.Playlist.HTTP.Full: instance GHC.Base.Monad m => GHC.Base.Functor (Text.Playlist.HTTP.Full.Download m)
+ Text.Playlist.HTTP.Full: instance GHC.Base.Functor m => GHC.Base.Functor (Text.Playlist.HTTP.Full.Download m)

Files

CHANGES.md view
@@ -1,3 +1,9 @@+# Version 0.2.0.0 (December 1, 2017)++  * Update to match `playlists` 0.5.0.0++  * Internally change from `EitherT` to `ExceptT`+ # Version 0.1.1.0 (February 5, 2017)    * Remove redundant constraints as reported by GHC 8.X.
playlists-http.cabal view
@@ -1,5 +1,5 @@ name:          playlists-http-version:       0.1.1.0+version:       0.2.0.0 synopsis:      Library to glue together playlists and http-client homepage:      https://github.com/pjones/playlists-http license:       BSD3@@ -10,7 +10,7 @@ category:      Text build-type:    Simple cabal-version: >= 1.18-tested-with:   GHC==7.10.3, GHC==8.0.1+tested-with:   GHC==7.10.3, GHC==8.0.2 description:   Simple library for resolving playlists using http-client.  --------------------------------------------------------------------------------@@ -52,12 +52,12 @@   build-depends: attoparsec   >= 0.10  && < 1.0                , base         >= 4.6   && < 5                , bytestring   >= 0.10  && < 1.0-               , either       >= 4.4   && < 4.5                , exceptions   >= 0.8   && < 0.9                , http-client  >= 0.4   && < 0.6                , mtl          >= 2.2   && < 2.3-               , playlists    >= 0.4   && < 0.5+               , playlists    >= 0.5   && < 0.6                , text         >= 0.11  && < 1.3+               , transformers >= 0.4   && < 0.6  -------------------------------------------------------------------------------- executable example
src/Text/Playlist/HTTP/Full.hs view
@@ -28,7 +28,7 @@ -- Package imports: import Control.Monad.Catch import Control.Monad.RWS.Strict-import Control.Monad.Trans.Either+import Control.Monad.Trans.Except import qualified Data.Attoparsec.ByteString as Atto import Data.ByteString (ByteString) import qualified Data.ByteString as ByteString@@ -79,7 +79,7 @@ -- | Internal type used for managing state, access to the environment, -- and access to IO. newtype Download m a =-  Download { runDownload :: RWST Environment () State (EitherT Error m) a }+  Download { runDownload :: RWST Environment () State (ExceptT Error m) a }    deriving ( Functor            , Applicative@@ -92,7 +92,7 @@ -------------------------------------------------------------------------------- -- | 'MonadThrow' instance for 'Download'. instance (Monad m) => MonadThrow (Download m) where-  throwM = Download . lift . left . FailedOnException . show+  throwM = Download . lift . throwE . FailedOnException . show  -------------------------------------------------------------------------------- -- | Internal helper function for getting a result out of a 'Download'@@ -103,7 +103,7 @@      -> State      -> m (Either Error (a, State)) runS d e s = do-  result <- runEitherT $ runRWST (runDownload d) e s+  result <- runExceptT $ runRWST (runDownload d) e s   case result of     Left err         -> return (Left err)     Right (x, s', _) -> return (Right (x, s'))@@ -133,7 +133,7 @@   ------------------------------------------------------------------------------   -- | Start playlist processing with the startURL.   go :: Download m Playlist-  go = resolve [Track startURL Nothing] fetch+  go = resolve [Track startURL Nothing Nothing] fetch    ------------------------------------------------------------------------------   -- | Turn a URL into a HTTP Request object.@@ -161,7 +161,11 @@   safeIO :: IO (Either Error a) -> Download m a   safeIO action = io (catch action stop)     where-      io a = Download (lift (hoistEither =<< liftIO a))+      io a = do x <- liftIO a+                case x of+                  Left e   -> Download . lift $ throwE e+                  Right x' -> return x'+       stop = return . Left . ProtocolError  --------------------------------------------------------------------------------@@ -173,7 +177,7 @@           -> Response BodyReader           -> Download m Playlist parseBody url response = do-    parser <- Download (lift (hoistEither lookupParser))+    parser <- Download (lift . ExceptT $ return lookupParser)     bytes  <- readChunk     dispatch (Atto.parse parser bytes) @@ -190,7 +194,7 @@     ----------------------------------------------------------------------------     -- | Dispatch an attoparsec response.     dispatch :: Atto.Result Playlist -> Download m Playlist-    dispatch (Atto.Fail _ _ err) = Download . lift $ left (FailedToParse err)+    dispatch (Atto.Fail _ _ err) = Download . lift $ throwE (FailedToParse err)     dispatch (Atto.Partial f)    = readChunk >>= dispatch . f     dispatch (Atto.Done _ r)     = return r @@ -202,7 +206,7 @@       count <- gets httpBytes        case check count of-        LimitReached -> Download . lift $ left ResponseTooLarge+        LimitReached -> Download . lift $ throwE ResponseTooLarge         Continue     -> do           bytes <- liftIO $ brRead (responseBody response)           modify' (\s -> s {httpBytes = ByteString.length bytes + count})