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

Add evalScan1 operator #2850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ghostbuster91
Copy link

@ghostbuster91 ghostbuster91 commented Mar 15, 2022

Hi,

I needed such operator today and as it wasn't trivial to write it, so I decided to commit it back to the fs2 repository.

@armanbilge
Copy link
Member

Sorry this has been sitting for so long 😕 I am going to close/re-open the PR to kick-start CI against the latest main.

@armanbilge armanbilge closed this Jan 3, 2023
@armanbilge armanbilge reopened this Jan 3, 2023
@ghostbuster91
Copy link
Author

@armanbilge No problem, thanks for looking into it :)

@ghostbuster91
Copy link
Author

There is some failing test but I don't think that it is connected:

fs2.concurrent.TopicSuite:
  + subscribers see all elements published 0.042s
==> X fs2.concurrent.TopicSuite.unregister subscribers under concurrent load  0.05s munit.ComparisonFailException: /home/runner/work/fs2/fs2/core/shared/src/test/scala/fs2/concurrent/TopicSuite.scala:114
113:        .map { result =>
114:          assertEquals(result.toMap.size, subs / 2)
115:          assertEquals(result.toMap, expected)
values are not the same
=> Obtained
6
=> Diff (- obtained, + expected)
-6
+5
    at munit.Assertions.failComparison(Assertions.scala:274)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)

@armanbilge
Copy link
Member

Yeah I think that's the known flake ...

Comment on lines +1049 to +1054
def go(z: O2, s: fs2.Stream[F2, O]): Pull[F2, O2, Unit] =
s.pull.uncons1.flatMap {
case Some((hd, tl)) =>
Pull.eval(f(z, hd)).flatMap(o => Pull.output1(o) >> go(o, tl))
case None => Pull.done
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this repeated from evalScan? Can we extract it into a private helper evalScan_ like is used for scan/scan1 ?

Copy link
Author

Choose a reason for hiding this comment

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

Sounds like a good idea, let me try it.

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.

None yet

2 participants