Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make defaultMakeClientRequest not depend on IO #1789

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions servant-client/src/Servant/Client/Internal/HttpClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,15 @@ clientResponseToResponse f r = Response
-- | Create a @http-client@ 'Client.Request' from a @servant@ 'Request'
-- The 'Client.host', 'Client.path' and 'Client.port' fields are extracted from the 'BaseUrl'
-- otherwise the body, headers and query string are derived from the @servant@ 'Request'
defaultMakeClientRequest :: BaseUrl -> Request -> IO Client.Request
defaultMakeClientRequest burl r = return Client.defaultRequest
--
-- Note that @Applicative@ dependency is not really needed for this function
-- implementation. But in the past the return type was wrapped into @IO@
-- without a necessity breaking the API backward-compatibility. In order to not
-- break the API again it was changed to @Applicative@ so that you can just use
-- something like @Data.Functor.Identity@ without a need to involve @IO@ but
-- still keeping it compatible with the code written when it was typed as @IO@.
defaultMakeClientRequest :: Applicative f => BaseUrl -> Request -> f Client.Request
defaultMakeClientRequest burl r = pure Client.defaultRequest
{ Client.method = requestMethod r
, Client.host = fromString $ baseUrlHost burl
, Client.port = baseUrlPort burl
Expand Down
Loading