-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Automatic derivation of querying functions for servant -- -- This library lets you derive automatically Haskell functions that let -- you query each endpoint of a servant webservice. -- -- See the client section of the tutorial. -- -- CHANGELOG @package servant-client @version 0.15 module Servant.Client.Internal.HttpClient -- | The environment in which a request is run. data ClientEnv ClientEnv :: Manager -> BaseUrl -> Maybe (TVar CookieJar) -> ClientEnv [manager] :: ClientEnv -> Manager [baseUrl] :: ClientEnv -> BaseUrl [cookieJar] :: ClientEnv -> Maybe (TVar CookieJar) -- | ClientEnv smart constructor. mkClientEnv :: Manager -> BaseUrl -> ClientEnv -- | Generates a set of client functions for an API. -- -- Example: -- --
-- type API = Capture "no" Int :> Get '[JSON] Int -- :<|> Get '[JSON] [Bool] -- -- api :: Proxy API -- api = Proxy -- -- getInt :: Int -> ClientM Int -- getBools :: ClientM [Bool] -- getInt :<|> getBools = client api --client :: HasClient ClientM api => Proxy api -> Client ClientM api -- | Change the monad the client functions live in, by supplying a -- conversion function (a natural transformation to be precise). -- -- For example, assuming you have some manager :: -- Manager and baseurl :: BaseUrl around: -- --
-- type API = Get '[JSON] Int :<|> Capture "n" Int :> Post '[JSON] Int -- api :: Proxy API -- api = Proxy -- getInt :: IO Int -- postInt :: Int -> IO Int -- getInt :<|> postInt = hoistClient api (flip runClientM cenv) (client api) -- where cenv = mkClientEnv manager baseurl --hoistClient :: HasClient ClientM api => Proxy api -> (forall a. m a -> n a) -> Client m api -> Client n api -- | ClientM is the monad in which client functions run. Contains -- the Manager and BaseUrl used for requests in the reader -- environment. newtype ClientM a ClientM :: ReaderT ClientEnv (ExceptT ServantError IO) a -> ClientM a [unClientM] :: ClientM a -> ReaderT ClientEnv (ExceptT ServantError IO) a runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a) performRequest :: Request -> ClientM Response clientResponseToResponse :: Response a -> GenResponse a requestToClientRequest :: BaseUrl -> Request -> Request catchConnectionError :: IO a -> IO (Either ServantError a) instance Control.Monad.Catch.MonadCatch Servant.Client.Internal.HttpClient.ClientM instance Control.Monad.Catch.MonadThrow Servant.Client.Internal.HttpClient.ClientM instance Control.Monad.Error.Class.MonadError Servant.Client.Core.Internal.Request.ServantError Servant.Client.Internal.HttpClient.ClientM instance Control.Monad.Reader.Class.MonadReader Servant.Client.Internal.HttpClient.ClientEnv Servant.Client.Internal.HttpClient.ClientM instance GHC.Generics.Generic (Servant.Client.Internal.HttpClient.ClientM a) instance Control.Monad.IO.Class.MonadIO Servant.Client.Internal.HttpClient.ClientM instance GHC.Base.Monad Servant.Client.Internal.HttpClient.ClientM instance GHC.Base.Applicative Servant.Client.Internal.HttpClient.ClientM instance GHC.Base.Functor Servant.Client.Internal.HttpClient.ClientM instance Control.Monad.Base.MonadBase GHC.Types.IO Servant.Client.Internal.HttpClient.ClientM instance Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO Servant.Client.Internal.HttpClient.ClientM instance Data.Functor.Alt.Alt Servant.Client.Internal.HttpClient.ClientM instance Servant.Client.Core.Internal.RunClient.RunClient Servant.Client.Internal.HttpClient.ClientM instance Servant.Client.Core.Internal.Generic.ClientLike (Servant.Client.Internal.HttpClient.ClientM a) (Servant.Client.Internal.HttpClient.ClientM a) -- | This module provides client which can automatically generate -- querying functions for each endpoint just from the type representing -- your API. module Servant.Client -- | Generates a set of client functions for an API. -- -- Example: -- --
-- type API = Capture "no" Int :> Get '[JSON] Int -- :<|> Get '[JSON] [Bool] -- -- api :: Proxy API -- api = Proxy -- -- getInt :: Int -> ClientM Int -- getBools :: ClientM [Bool] -- getInt :<|> getBools = client api --client :: HasClient ClientM api => Proxy api -> Client ClientM api -- | ClientM is the monad in which client functions run. Contains -- the Manager and BaseUrl used for requests in the reader -- environment. data ClientM a runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a) -- | The environment in which a request is run. data ClientEnv ClientEnv :: Manager -> BaseUrl -> Maybe (TVar CookieJar) -> ClientEnv [manager] :: ClientEnv -> Manager [baseUrl] :: ClientEnv -> BaseUrl [cookieJar] :: ClientEnv -> Maybe (TVar CookieJar) -- | ClientEnv smart constructor. mkClientEnv :: Manager -> BaseUrl -> ClientEnv -- | Change the monad the client functions live in, by supplying a -- conversion function (a natural transformation to be precise). -- -- For example, assuming you have some manager :: -- Manager and baseurl :: BaseUrl around: -- --
-- type API = Get '[JSON] Int :<|> Capture "n" Int :> Post '[JSON] Int -- api :: Proxy API -- api = Proxy -- getInt :: IO Int -- postInt :: Int -> IO Int -- getInt :<|> postInt = hoistClient api (flip runClientM cenv) (client api) -- where cenv = mkClientEnv manager baseurl --hoistClient :: HasClient ClientM api => Proxy api -> (forall a. m a -> n a) -> Client m api -> Client n api module Servant.Client.Internal.HttpClient.Streaming -- | ClientM is the monad in which client functions run. Contains -- the Manager and BaseUrl used for requests in the reader -- environment. newtype ClientM a ClientM :: ReaderT ClientEnv (ExceptT ServantError (Codensity IO)) a -> ClientM a [unClientM] :: ClientM a -> ReaderT ClientEnv (ExceptT ServantError (Codensity IO)) a -- | Generates a set of client functions for an API. -- -- Example: -- --
-- type API = Capture "no" Int :> Get '[JSON] Int -- :<|> Get '[JSON] [Bool] -- -- api :: Proxy API -- api = Proxy -- -- getInt :: Int -> ClientM Int -- getBools :: ClientM [Bool] -- getInt :<|> getBools = client api --client :: HasClient ClientM api => Proxy api -> Client ClientM api -- | Change the monad the client functions live in, by supplying a -- conversion function (a natural transformation to be precise). -- -- For example, assuming you have some manager :: -- Manager and baseurl :: BaseUrl around: -- --
-- type API = Get '[JSON] Int :<|> Capture "n" Int :> Post '[JSON] Int -- api :: Proxy API -- api = Proxy -- getInt :: IO Int -- postInt :: Int -> IO Int -- getInt :<|> postInt = hoistClient api (flip runClientM cenv) (client api) -- where cenv = mkClientEnv manager baseurl --hoistClient :: HasClient ClientM api => Proxy api -> (forall a. m a -> n a) -> Client m api -> Client n api withClientM :: ClientM a -> ClientEnv -> (Either ServantError a -> IO b) -> IO b -- | A runClientM variant for streaming client. -- -- It allows using this module's ClientM in a direct style. The -- NFData constraint however prevents using this function with -- genuine streaming response types (SourceT, Conduit, -- pipes Proxy or Machine). For those you have to use -- withClientM. -- -- Note: we force the result, so the likehood of -- accidentally leaking a connection is smaller. Use with care. runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ServantError a) performRequest :: Request -> ClientM Response performWithStreamingRequest :: Request -> (StreamingResponse -> IO a) -> ClientM a -- | The environment in which a request is run. data ClientEnv ClientEnv :: Manager -> BaseUrl -> Maybe (TVar CookieJar) -> ClientEnv [manager] :: ClientEnv -> Manager [baseUrl] :: ClientEnv -> BaseUrl [cookieJar] :: ClientEnv -> Maybe (TVar CookieJar) -- | ClientEnv smart constructor. mkClientEnv :: Manager -> BaseUrl -> ClientEnv clientResponseToResponse :: Response a -> GenResponse a requestToClientRequest :: BaseUrl -> Request -> Request catchConnectionError :: IO a -> IO (Either ServantError a) instance Control.Monad.Error.Class.MonadError Servant.Client.Core.Internal.Request.ServantError Servant.Client.Internal.HttpClient.Streaming.ClientM instance Control.Monad.Reader.Class.MonadReader Servant.Client.Internal.HttpClient.ClientEnv Servant.Client.Internal.HttpClient.Streaming.ClientM instance GHC.Generics.Generic (Servant.Client.Internal.HttpClient.Streaming.ClientM a) instance Control.Monad.IO.Class.MonadIO Servant.Client.Internal.HttpClient.Streaming.ClientM instance GHC.Base.Monad Servant.Client.Internal.HttpClient.Streaming.ClientM instance GHC.Base.Applicative Servant.Client.Internal.HttpClient.Streaming.ClientM instance GHC.Base.Functor Servant.Client.Internal.HttpClient.Streaming.ClientM instance Control.Monad.Base.MonadBase GHC.Types.IO Servant.Client.Internal.HttpClient.Streaming.ClientM instance Data.Functor.Alt.Alt Servant.Client.Internal.HttpClient.Streaming.ClientM instance Servant.Client.Core.Internal.RunClient.RunClient Servant.Client.Internal.HttpClient.Streaming.ClientM instance Servant.Client.Core.Internal.RunClient.RunStreamingClient Servant.Client.Internal.HttpClient.Streaming.ClientM instance Servant.Client.Core.Internal.Generic.ClientLike (Servant.Client.Internal.HttpClient.Streaming.ClientM a) (Servant.Client.Internal.HttpClient.Streaming.ClientM a) -- | This module provides client which can automatically generate -- querying functions for each endpoint just from the type representing -- your API. -- -- This client supports streaming operations. module Servant.Client.Streaming -- | Generates a set of client functions for an API. -- -- Example: -- --
-- type API = Capture "no" Int :> Get '[JSON] Int -- :<|> Get '[JSON] [Bool] -- -- api :: Proxy API -- api = Proxy -- -- getInt :: Int -> ClientM Int -- getBools :: ClientM [Bool] -- getInt :<|> getBools = client api --client :: HasClient ClientM api => Proxy api -> Client ClientM api -- | ClientM is the monad in which client functions run. Contains -- the Manager and BaseUrl used for requests in the reader -- environment. data ClientM a withClientM :: ClientM a -> ClientEnv -> (Either ServantError a -> IO b) -> IO b -- | A runClientM variant for streaming client. -- -- It allows using this module's ClientM in a direct style. The -- NFData constraint however prevents using this function with -- genuine streaming response types (SourceT, Conduit, -- pipes Proxy or Machine). For those you have to use -- withClientM. -- -- Note: we force the result, so the likehood of -- accidentally leaking a connection is smaller. Use with care. runClientM :: NFData a => ClientM a -> ClientEnv -> IO (Either ServantError a) -- | The environment in which a request is run. data ClientEnv ClientEnv :: Manager -> BaseUrl -> Maybe (TVar CookieJar) -> ClientEnv [manager] :: ClientEnv -> Manager [baseUrl] :: ClientEnv -> BaseUrl [cookieJar] :: ClientEnv -> Maybe (TVar CookieJar) -- | ClientEnv smart constructor. mkClientEnv :: Manager -> BaseUrl -> ClientEnv -- | Change the monad the client functions live in, by supplying a -- conversion function (a natural transformation to be precise). -- -- For example, assuming you have some manager :: -- Manager and baseurl :: BaseUrl around: -- --
-- type API = Get '[JSON] Int :<|> Capture "n" Int :> Post '[JSON] Int -- api :: Proxy API -- api = Proxy -- getInt :: IO Int -- postInt :: Int -> IO Int -- getInt :<|> postInt = hoistClient api (flip runClientM cenv) (client api) -- where cenv = mkClientEnv manager baseurl --hoistClient :: HasClient ClientM api => Proxy api -> (forall a. m a -> n a) -> Client m api -> Client n api