HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleservant-client-0.20.2Haskell2010

Servant.Client.Internal.HttpClient.Streaming

  • 2 types
  • 10 values
valueclient :: HasClient ClientM api => Proxy api -> Client ClientM api
#

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
newtypenewtype ClientM a
#

ClientM is the monad in which client functions run. Contains the Manager and BaseUrl used for requests in the reader environment.

Instances12Monad, Functor, Applicative, MonadIO, Alt, RunClient, …
  • Monad ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • Functor ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • Applicative ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • MonadIO ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • Alt ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming

    Try clients in order, last error is preserved.

  • RunClient ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • RunStreamingClient ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • MonadError ClientError ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • MonadReader ClientEnv ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • MonadBase IO ClientMDefined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • Generic (ClientM a)Defined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
  • type Rep (ClientM a) = Rep (ReaderT ClientEnv (ExceptT ClientError (Codensity IO)) a)Defined in servant-client-0.20.2 · Servant.Client.Internal.HttpClient.Streaming
valuehoistClient
  1. :: HasClient ClientM api
  2. => Proxy api
  3. -> forall a. m a -> n a
  4. -> Client m api
  5. -> Client n 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
datadata ClientEnv
#

The environment in which a request is run. The baseUrl and makeClientRequest function are used to create a http-client request. Cookies are then added to that request if a CookieJar is set on the environment. Finally the request is executed with the manager. The makeClientRequest function can be used to modify the request to execute and set values which are not specified on a servant Request like responseTimeout or redirectCount

Constructors

Instances2MonadReader