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

Create instances for ToContent Void, ToTypedContent Void #1752

Merged
merged 3 commits into from
Mar 24, 2022

Conversation

lykahb
Copy link
Contributor

@lykahb lykahb commented Mar 22, 2022

Some handlers never respond with the success response. They always redirect, sendFile or return some other error. Giving them the type Handler () implies that they may return an empty success response. The type Handler Void is more precise and helps to understand the handler behavior at a glance.


Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

Copy link
Member

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

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

LGTM! Just out of curiosity, what’s the use case where this came up?

@snoyberg snoyberg merged commit c74fc99 into yesodweb:master Mar 24, 2022
@lykahb
Copy link
Contributor Author

lykahb commented Mar 24, 2022

There were two use cases where the specific type was used only to make the handler content type monomorphic:

  • a handler with sendResponse ("application/pdf" :: ContentType, content). I replaced this exception-based response with Handler (ContentType, Content).
  • a handler that sends sendStatusJSON Status.status202 payload on its happy path. For that one the Handler Void is the most fitting type

@snoyberg
Copy link
Member

Got it thanks!

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.

2 participants