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
Newtype blocking execution contexts #555
Comments
We use this technique in quasar and it works wonderfully. I'd be in favor, but obviously the hour is very very late on 2.0. I'm okay sneaking it in since it's purely additive, but I'd like to hear from more. (hailing @ChristopherDavenport in particular) |
We used a similar technique at work too. Less chances to make a mistake like passing I think it's a pretty small addition in terms of lines of code but immensely useful, having it in |
+1, this will make APIs like fs2's files more explicit about the type of EC expected. |
I am pretty strongly in favour :) |
Handcrafted this in all production apps that use cats-effect, so it would be really useful to just ship directly in cats-effect 😄 |
Sounds effectively equivalent to linebacker which was rejected due to doing more than others wanted. I think |
I strongly disagree on Re: linebacker, I agree though note |
I'd really like a newtype of
ExecutionContext
that indicates the context is to be used for blocking tasks. Additionally, the newtype could provide good default constructors and convenience methods. I'm roughly thinking of something like this:I believe this type would help prevent folks from using the wrong execution context for blocking operations. I'm somewhat in favor of not including
unsafeFromExecutionContext
at all, though I can see how that would be annoying.It would be really nice if this could get in to the 2.0.0 release. It might change or be removed for 3.0 but that's okay -- I see it as a companion to the current
ContextShift
type class.Blocker
definitely treads on the ground covered by linebacker, though I think it's better to keep the newtype unaware of the type constructor you might use with it.Thoughts? If there's interest, I can prepare a PR.
The text was updated successfully, but these errors were encountered: