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

servant-client: Run ClientEnv's makeClientRequest in IO #1595

Merged
merged 2 commits into from
Jul 1, 2022

Conversation

Minnozz
Copy link
Contributor

@Minnozz Minnozz commented Jun 17, 2022

Use cases:

@tchoutri
Copy link
Contributor

@Minnozz Hi! Has there been a discussion about this PR? :)

@Minnozz
Copy link
Contributor Author

Minnozz commented Jun 17, 2022

@tchoutri Hi! This change was suggested by alp__ on IRC today in response to a question from me. I took a shot at implementing it; should it also be discussed elsewhere?

@tchoutri
Copy link
Contributor

Great, then I'll leave @alpmestan review your PR. :)

Copy link
Contributor

@alpmestan alpmestan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. We'll want to add an entry in the relevant changelog. Also, this will force a major version bump.

Let's perhaps leave a few days to give others a chance to give feedback on this, and for you to add a changelog entry (see how other PRs do it, with entries in the changelog.d directory).

servant-client/test/Servant/SuccessSpec.hs Show resolved Hide resolved
@Minnozz
Copy link
Contributor Author

Minnozz commented Jun 21, 2022

@alpmestan I added a changelog entry, do you think it needs more explanation?

@alpmestan
Copy link
Contributor

@Minnozz Should be fine, I think people using servant are familiar enough with IO =)

If you ever feel like writing down a little something that demonstrates how you're using this to your advantage (cookbook recipe, blog post, whatever), then it can serve as a reference for users who might need this in the future. But that's more work that adding a few lines in the changelog :-)

@tchoutri
Copy link
Contributor

tchoutri commented Jul 1, 2022

Considering the approval of this PR, I will merge, but a cookbook or a blog post would be very appreciated, @Minnozz :)

@tchoutri tchoutri merged commit 489cbd5 into haskell-servant:master Jul 1, 2022
@unclechu
Copy link
Contributor

Please have a look at #1787 trying to read this change through I can’t say why this change is necessary. Why was it worth to break the API? Why does it have to be exactly IO? Etc. etc.

@Minnozz
Copy link
Contributor Author

Minnozz commented Sep 30, 2024

@unclechu The change was necessary for my project to be able to call applyDigestAuth, as is noted in the description of this PR. As for requiring precisely IO: as a Haskell novice I did not understand the difference between IO and MonadIO when I made this PR; feel free to propose a PR with a better API :)

@tchoutri
Copy link
Contributor

tchoutri commented Oct 1, 2024

+1, submit a PR to depend on MonadIO, it would be an improvement.

@unclechu
Copy link
Contributor

unclechu commented Oct 1, 2024

@Minnozz

The change was necessary for my project to be able to call applyDigestAuth

I don’t think it was necessary, you could always call defaultMakeClientRequest by prefixing it with pure/return in-place. Or am I missing something?

MonadIO constraint is also an overkill. Applicative is enough as a dependency to do the same thing.

I’ll make a pull request.

@Minnozz
Copy link
Contributor Author

Minnozz commented Oct 1, 2024

It's not about defaultMakeClientRequest, it's about being able to configure ClientEnv with a different makeClientRequest function that requires IO (like applyDigestAuth)

@unclechu
Copy link
Contributor

unclechu commented Oct 1, 2024

I would just mean the only change required is for ClientEnv but defaultMakeClientRequest didn’t have to be changed.

unclechu added a commit to unclechu/servant that referenced this pull request Oct 1, 2024
The `IO` wrap for the return type of this function was never necessary.
Inside the function there’s only `return` call that wraps a _pure_ value
into `IO`. There is nothing else that would be related to `IO`.
The `IO` wrap was introduced in 9df16f9

In order to not break the API again the wrap was preserved but this
change makes it to depend on any `Applicative` instead of `IO`.
So it still works in `IO`/`MonadIO` context but allows to use something
like `Data.Functor.Identity` to work with _pure_ values.

See for more context:
haskell-servant#1595
@unclechu
Copy link
Contributor

unclechu commented Oct 1, 2024

The change for the defaultMakeClientRequest return type: #1789

tchoutri pushed a commit that referenced this pull request Oct 1, 2024
The `IO` wrap for the return type of this function was never necessary.
Inside the function there’s only `return` call that wraps a _pure_ value
into `IO`. There is nothing else that would be related to `IO`.
The `IO` wrap was introduced in 9df16f9

In order to not break the API again the wrap was preserved but this
change makes it to depend on any `Applicative` instead of `IO`.
So it still works in `IO`/`MonadIO` context but allows to use something
like `Data.Functor.Identity` to work with _pure_ values.

See for more context:
#1595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants