-
Notifications
You must be signed in to change notification settings - Fork 605
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
zip + uncons + concurrency = scope lookup failure #3478
Comments
possible dupe of #3123? In any case, I liked the idea I had there
but I couldn't quite make that work. |
Oh sorry, I didn't see that other issue. |
And to underscore how little I understand of the scope system, if you replace |
When unconsing, the tail of the stream is (effectively) prefixed with an Here is an example: When you do I've experimented a bit with a non-cps based What does scope lookup mean?In fs2 scope's are referenced by The For instance, for Say we'd like to compile a Say this tail // A diamond structure of effect structures
trait Effect1[A]
trait Effect2[A]
trait SubEffect[A] extends Effect1[A] with Effect2[A]
val myResource: Resource[SubEffect, Int] = ???
Stream
.resource(myResource)
.repeatN(3)
.pull
.uncons1
.flatMap{
case None => Pull.done
case Some((hd, tl)) =>
// notice that tl is now evaluated in Effect1, but the origin stream still remains in SubEffect
tl.covary[Effect1].compile.drain
}
.stream
// the stream will be compiled in Effect2 which does not share any partial ordering with Effect1
.covary[Effect2]
.compile.drain In my experiment I have explicitly encoded this issue here. In fs2, instead an exception is (justifiably) thrown when By taking the liberty to introduce So what if we just make sure to only open scopes in
I spent a while trying to grok the whys in fs2 and want to contribute to making a sound and expressive streaming model. So any discussion is much appreciated! Disregarding soundness issues of moving scopes between effects, @armanbilge, what issues did you hit when passing the active scope to the background stream in |
Quoting @armanbilge:
I ran into this issue before here: #3081 (comment)
IIUC Arman worked around that problem for
hold1
by moving the.pull.uncons
into the concurrent process. However the core issue still remains: if you dostream.pull.uncons
and then concurrently process the tail, things will blow up ifstream
happens to contain any kind of zipping. Possibly other operators that are implemented withstepLeg
have the same issue?I ran into this again while trying to use
Pull.extendScopeTo
for extending resource lifetimes across async boundaries. That actually seems to work, but requiresstream.pull.peek
or any other unconsing variation, which means it's incompatible with zipped streams:https://scastie.scala-lang.org/56CQGK8uTzecITHSwmO0AQ
The text was updated successfully, but these errors were encountered: