monad-http-0.1.0.0: A class of monads which can do http requests

Copyright(C) 2015 Futurice Oy
LicenseBSD-3-Clause
MaintainerOleg Grenrus <oleg.grenrus@iki.fi>
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Http.Class

Description

 

Synopsis

Documentation

class Monad m => MonadHttp m where #

The monad capable to do HTTP requests.

Minimal complete definition

withResponse

Methods

withResponse :: Request -> (Response (BodyReaderM m) -> m a) -> m a #

Get a single chunk of data from the response body, or an empty bytestring if no more data is available.

Note that in order to consume the entire request body, you will need to repeatedly call this function until you receive an empty ByteString as a result.

brRead :: BodyReaderM m -> m ByteString #

Instances

MonadHttp m => MonadHttp (MaybeT m) # 
MonadHttp m => MonadHttp (NoLoggingT m) # 
MonadHttp m => MonadHttp (LoggingT m) # 
(~) (* -> *) m IO => MonadHttp (HttpT m) #

TODO: Generalise to MonadIO + MonadMask?

MonadHttp m => MonadHttp (RandT g m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (RandT g m)) -> RandT g m a) -> RandT g m a #

brRead :: BodyReaderM (RandT g m) -> RandT g m ByteString #

(MonadHttp m, Monoid w) => MonadHttp (WriterT w m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (WriterT w m)) -> WriterT w m a) -> WriterT w m a #

brRead :: BodyReaderM (WriterT w m) -> WriterT w m ByteString #

(MonadHttp m, Monoid w) => MonadHttp (WriterT w m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (WriterT w m)) -> WriterT w m a) -> WriterT w m a #

brRead :: BodyReaderM (WriterT w m) -> WriterT w m ByteString #

MonadHttp m => MonadHttp (StateT r m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (StateT r m)) -> StateT r m a) -> StateT r m a #

brRead :: BodyReaderM (StateT r m) -> StateT r m ByteString #

MonadHttp m => MonadHttp (StateT r m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (StateT r m)) -> StateT r m a) -> StateT r m a #

brRead :: BodyReaderM (StateT r m) -> StateT r m ByteString #

(MonadHttp m, Error e) => MonadHttp (ErrorT e m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (ErrorT e m)) -> ErrorT e m a) -> ErrorT e m a #

brRead :: BodyReaderM (ErrorT e m) -> ErrorT e m ByteString #

MonadHttp m => MonadHttp (ExceptT e m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (ExceptT e m)) -> ExceptT e m a) -> ExceptT e m a #

brRead :: BodyReaderM (ExceptT e m) -> ExceptT e m ByteString #

MonadHttp m => MonadHttp (IdentityT * m) # 
MonadHttp m => MonadHttp (ReaderT * r m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (ReaderT * r m)) -> ReaderT * r m a) -> ReaderT * r m a #

brRead :: BodyReaderM (ReaderT * r m) -> ReaderT * r m ByteString #

MonadHttp m => MonadHttp (CRandT g e m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (CRandT g e m)) -> CRandT g e m a) -> CRandT g e m a #

brRead :: BodyReaderM (CRandT g e m) -> CRandT g e m ByteString #

(MonadHttp m, Monoid w) => MonadHttp (RWST r w s m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (RWST r w s m)) -> RWST r w s m a) -> RWST r w s m a #

brRead :: BodyReaderM (RWST r w s m) -> RWST r w s m ByteString #

(MonadHttp m, Monoid w) => MonadHttp (RWST r w s m) # 

Methods

withResponse :: Request -> (Response (BodyReaderM (RWST r w s m)) -> RWST r w s m a) -> RWST r w s m a #

brRead :: BodyReaderM (RWST r w s m) -> RWST r w s m ByteString #

httpLbs :: MonadHttp m => Request -> m (Response ByteString) #

A convenience wrapper around withResponse which reads in the entire response body and immediately releases resources.

brConsume :: MonadHttp m => BodyReaderM m -> m [ByteString] #

Strictly consume all remaining chunks of data from the stream.