Add compute combinators - #4190
Conversation
3714fd7 to
d0950f7
Compare
d0950f7 to
e84d14b
Compare
|
I would like to weigh in a little. Thereby, Is it really important to have |
|
That said, |
As with any combinator is hard to argue both ways IMHO. Personally, I like avoiding the |
|
I'd also be inclined to remove the attempt versions. These combinators are already slightly niche, and having Also, the |
Well, actually, the last time I needed this it was with that shape :p As I said in my previous message, it is hard to argue which combinators should exist and which should not. I just think we need at least the two basic |
Ya, those made sense to me. It's just the attempt shape and name I object to. I could see an argument that only I worry a little this whole exercise will result in people casually throwing a compute on anything that does CPU bound work at all, but that's not even a footgun. |
| * @see | ||
| * [[delay]] for more details | ||
| */ | ||
| def compute[A](thunk: => A): F[A] = |
There was a problem hiding this comment.
This having to be in Async feels bad. Is there a reason we shouldn't implement it as F.defer(F.pure(thunk)) instead of delay(thunk)? delay is supposed to be for side effects, but the computations should be pure.
There was a problem hiding this comment.
Or even a cheeky F.unit.map(_ => thunk). It wouldn't be the first use of the trick in this codebase.
Related to #3353
Adds a couple of useful combinators related to compute-bound operations.
How best to suspend compute-bound operations is a FAQ in Discord, thus I believe having some combinators for the simple use cases is a good idea.