free-http 0.1.1.1 → 0.1.1.2
raw patch · 2 files changed
+37/−9 lines, 2 files
Files
free-http.cabal view
@@ -1,6 +1,6 @@ name: free-http -version: 0.1.1.1+version: 0.1.1.2 synopsis: An HTTP Client based on Free Monads.
src/Network/HTTP/Client/Free/HttpClient.hs view
@@ -34,9 +34,15 @@ ------------------------------------------------------------------------------- -- | Peel a layer of the 'HttpF' functor and run an http request with the data -- provided.-iterTHttp :: (Monad m, MonadIO m)+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+ ) => Manager- -> HttpF HttpClient (m a)+ -> HttpF client (m a) -> m a iterTHttp manager (HttpF m r next) = let !req = setMethod m r in liftIO (httpLbs req manager) >>= next@@ -44,9 +50,17 @@ ------------------------------------------------------------------------------- -- | 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 :: (Monad m, MonadTrans t, Monad (t m), MonadIO 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)+ , MonadIO m+ ) => Manager- -> HttpF HttpClient (t m a)+ -> HttpF client (t m a) -> t m a iterTMHttp manager (HttpF m r next) = let !req = setMethod m r in (lift . liftIO $ httpLbs req manager) >>= next@@ -54,9 +68,15 @@ ------------------------------------------------------------------------------- -- | 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 :: (Monad m, MonadIO m)+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+ ) => Manager- -> FT (HttpF HttpClient) m a+ -> FT (HttpF client) m a -> m a runHttp manager = iterT (iterTHttp manager) @@ -64,8 +84,16 @@ -- | The main http-client interpreter. The client is free to specify the base -- effect monad ('m'), and in thise case this the result can be lifted into a -- higher monad transformer stack ('t')-runTHttp :: (Monad m, MonadIO m, MonadTrans t, Monad (t m))+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+ , Monad (t m)+ ) => Manager- -> FT (HttpF HttpClient) m a+ -> FT (HttpF client) m a -> t m a runTHttp manager = iterTM (iterTMHttp manager)