http-wget 0.6.0.1 → 0.6.1
raw patch · 2 files changed
+54/−10 lines, 2 filesdep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: transformers
API changes (from Hackage documentation)
+ Network.HTTP.Wget: instance Applicative SplitHelper
+ Network.HTTP.Wget: instance Failure WgetException SplitHelper
+ Network.HTTP.Wget: instance Functor SplitHelper
+ Network.HTTP.Wget: instance Monad SplitHelper
+ Network.HTTP.Wget: instance MonadIO SplitHelper
+ Network.HTTP.Wget: wgetSplit :: (MonadFailure WgetException m) => String -> [(String, String)] -> [(String, String)] -> IO (m String)
+ Network.HTTP.Wget: wgetSplit' :: (MonadFailure WgetException m) => String -> [(String, String)] -> [(String, String)] -> IO (m ([(String, String)], String))
Files
- Network/HTTP/Wget.hs +52/−1
- http-wget.cabal +2/−9
Network/HTTP/Wget.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PackageImports #-}+{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE CPP #-} --------------------------------------------------------- -- |@@ -18,6 +19,8 @@ module Network.HTTP.Wget ( wget , wget'+ , wgetSplit+ , wgetSplit' , WgetException (..) ) where @@ -26,7 +29,7 @@ import System.IO import Numeric (showHex) import Data.List (intercalate)-#if TRANSFORMERS_02+#if MIN_VERSION_transformers(0,2,0) import "transformers" Control.Monad.IO.Class #else import "transformers" Control.Monad.Trans@@ -36,10 +39,58 @@ import Data.Generics import Data.Char (isSpace) import Control.Arrow (first, second)+import Control.Monad+import Control.Applicative newtype WgetException = WgetException String deriving (Show, Typeable) instance Exception WgetException++newtype SplitHelper x = SplitHelper+ { unSplitHelper :: IO (Either WgetException x)+ }++instance Functor SplitHelper where+ fmap = liftM+instance Applicative SplitHelper where+ pure = return+ (<*>) = ap+instance Monad SplitHelper where+ return = SplitHelper . return . Right+ x >>= f = SplitHelper $ do+ x' <- unSplitHelper x+ case x' of+ Left e -> return $ Left e+ Right v -> unSplitHelper $ f v+instance Failure WgetException SplitHelper where+ failure = SplitHelper . return . Left+instance MonadIO SplitHelper where+ liftIO = SplitHelper . fmap Right++splitException :: MonadFailure WgetException m+ => SplitHelper x+ -> IO (m x)+splitException i = do+ x <- unSplitHelper i+ case x of+ Left e -> return $ failure e+ Right v -> return $ return v++-- | Same as 'wget', but easier to access the exception on failure.+wgetSplit :: MonadFailure WgetException m+ => String -- ^ The URL.+ -> [(String, String)] -- ^ Get parameters.+ -> [(String, String)] -- ^ Post parameters. If empty, this will be a get request.+ -> IO (m String) -- ^ The headers and response body.+wgetSplit url get post = splitException $ wget url get post++-- | Same as wget\', but easier to access the exception on failure.+wgetSplit' :: MonadFailure WgetException m+ => String -- ^ The URL.+ -> [(String, String)] -- ^ Get parameters.+ -> [(String, String)] -- ^ Post parameters. If empty, this will be a get request.+ -> IO (m ([(String, String)], String)) -- ^ The headers and response body.+wgetSplit' url get post = splitException $ wget' url get post -- | Get a response from the given URL with the given parameters. wget :: (MonadIO m, MonadFailure WgetException m)
http-wget.cabal view
@@ -1,5 +1,5 @@ name: http-wget-version: 0.6.0.1+version: 0.6.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -16,18 +16,11 @@ build-type: Simple homepage: http://github.com/snoyberg/http-wget/tree/master -flag transformers_02- description: transformers = 0.2.*- library build-depends: base >= 4 && < 5, process >= 1.0.1.1 && < 1.1, failure >= 0.0.0 && < 0.1,+ transformers >= 0.1 && < 0.3, syb- if flag(transformers_02)- build-depends: transformers >= 0.2 && < 0.3- CPP-OPTIONS: -DTRANSFORMERS_02- else- build-depends: transformers >= 0.1 && < 0.2 exposed-modules: Network.HTTP.Wget ghc-options: -Wall