packages feed

free-http 0.1.1.3 → 0.2.0

raw patch · 3 files changed

+33/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Network.HTTP.Client.Free: [HttpF] :: StdMethod -> (RequestType client) -> (ResponseType client -> a) -> HttpF client a
- Network.HTTP.Client.Free.Types: [HttpF] :: StdMethod -> (RequestType client) -> (ResponseType client -> a) -> HttpF client a
- Network.HTTP.Client.Free.Types: instance Functor (HttpF client)
+ Network.HTTP.Client.Free: HttpF :: StdMethod -> (RequestType client) -> (ResponseType client -> a) -> HttpF client a
+ Network.HTTP.Client.Free: natHttpF :: (RequestType client1 -> RequestType client2) -> (ResponseType client2 -> ResponseType client1) -> HttpF client1 a -> HttpF client2 a
+ Network.HTTP.Client.Free: transHttp :: Monad m => (RequestType client1 -> RequestType client2) -> (ResponseType client2 -> ResponseType client1) -> FreeHttp client1 m a -> FreeHttp client2 m a
+ Network.HTTP.Client.Free.Types: HttpF :: StdMethod -> (RequestType client) -> (ResponseType client -> a) -> HttpF client a
+ Network.HTTP.Client.Free.Types: instance GHC.Base.Functor (Network.HTTP.Client.Free.Types.HttpF client)

Files

free-http.cabal view
@@ -1,6 +1,6 @@ name:                free-http -version:             0.1.1.3+version:             0.2.0  synopsis:            An HTTP Client based on Free Monads. 
src/Network/HTTP/Client/Free.hs view
@@ -1,5 +1,6 @@ {-| The primary Free Monad wrapping HTTP actions. -}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-}  module Network.HTTP.Client.Free (@@ -16,6 +17,10 @@     -- ** A helpful type alias     , FreeHttp +    -- * Handy morphisms for working with HttpF+    , natHttpF+    , transHttp+     -- * smart constructors for http verbs     , connect     , delete@@ -29,7 +34,7 @@  ) where -import Control.Monad.Trans.Free.Church (FT, liftF)+import Control.Monad.Trans.Free.Church (FT, liftF, transFT) import Network.HTTP.Client (httpLbs, Manager, Request, Response) import Network.HTTP.Client.Free.Types (FreeHttp, HttpF(HttpF), RequestType, ResponseType) import Network.HTTP.Types.Method (StdMethod(..))@@ -79,3 +84,19 @@       => RequestType client       -> FT (HttpF client) m (ResponseType client) patch req = liftF (HttpF PATCH req id)++-- | A natural transformation between 'HttpF' types.+natHttpF :: (RequestType client1 -> RequestType client2)+        -> (ResponseType client2 -> ResponseType client1)+        -> HttpF client1 a+        -> HttpF client2 a+natHttpF reqT respT (HttpF method req resp) = HttpF method (reqT req) (resp . respT)++-- | 'transHttp' allows clients to mix-and-match http request and response+-- foundations, so long as there is an appropriate morphism.+transHttp :: Monad m+          => (RequestType client1 -> RequestType client2)+          -> (ResponseType client2 -> ResponseType client1)+          -> FreeHttp client1 m a+          -> FreeHttp client2 m a+transHttp reqT respT = transFT (natHttpF reqT respT)
src/Network/HTTP/Client/Free/HttpClient.hs view
@@ -34,8 +34,10 @@ ------------------------------------------------------------------------------- -- | Peel a layer of the 'HttpF' functor and run an http request with the data -- provided.-iterTHttp :: ( Request ~ RequestType client-             , Response ByteString ~ ResponseType client+iterTHttp :: ( Request ~ RequestType client +                -- The foundational request must be of type 'Request'+             , Response ByteString ~ ResponseType client +                -- The foundational response must be of type 'Response ByteString'              , Monad m              , MonadIO m              )@@ -49,7 +51,9 @@ -- | Peel a layer of the 'HttpF' functor and run an http request with the data. -- the base monad for this action is 't m'. iterTMHttp :: ( Request ~ RequestType client+             -- The foundational request must be of type 'Request'               , Response ByteString ~ ResponseType client+             -- The foundational response must be of type 'Response ByteString'               , Monad m               , MonadTrans t               , Monad (t m)@@ -65,7 +69,9 @@ -- | The main http-client interpreter. The client is free to specify the base -- effect monad so long as there is an instance of 'MonadIO' for it in scope. runHttp :: ( Request ~ RequestType client+           -- The foundational request must be of type 'Request'            , Response ByteString ~ ResponseType client+           -- The foundational response must be of type 'Response ByteString'            , Monad m            , MonadIO m            )@@ -79,7 +85,9 @@ -- effect monad ('m'), and in thise case this the result can be lifted into a -- higher monad transformer stack ('t') runTHttp :: ( Request ~ RequestType client+            -- The foundational request must be of type 'Request'             , Response ByteString ~ ResponseType client+            -- The foundational response must be of type 'Response ByteString'             , Monad m             , MonadIO m             , MonadTrans t