I think we can all agree fibers are hard to work with and probably what users shouldn't use 90% of the time. There are plenty of valid usecases at this moment though, for example starting an IO in background and cancelling it in case the application wraps up, which can be implemented with something like Resource(fa.start.fproduct(_.cancel)).
We should support that usecase and others and expose a method that'd look roughly like this:
def startResource: Resource[F, Fiber[A]]
//or
//the nested F is `join` without access to the finalizer
def startResource: Resource[F, F[A]]
in Concurrent or (as syntax in ConcurrentOps && as method on IO).
Name suggestions welcome - I'd go for background or startResource. Once we've figured out the appropriate shape and name I can provide an implementation.
Gitter microdiscussions:
馃憤 for the second variant
I think so as well. If someone wants to cancel from within, they can probably use a Deferred or something like that.
Eh, I think the first signature is a lot more intuitive and there's not much, if any, safety gained by hiding the cancel here. (Nah I'm not saying that because the first variant is in ZIO i swear on me mum)
The first signature does have the example of names, but I just feel it's really weird to make a resource-safe abstraction around something and then鈥β爀xpose the release action for that resource as a bare F[Unit]. I dunno. It's not too much of a problem since cancelation is idempotent, but still.
type JoinToken? ;)
LOL. I still really hate CancelToken, even though I see the value in it as a name. Confuses me every time.
For now I'll go with background because it's a meaningful name and it might be what people ctrl+F for (bonus points for not being startResource which I don't really like). We can bikeshed on the PR :)
Most helpful comment
馃憤 for the second variant