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 withFilter to Stream in order to filter in for comprehensions #1971

Closed
hogiyogi597 opened this issue Jul 28, 2020 · 3 comments · Fixed by #1972
Closed

Add withFilter to Stream in order to filter in for comprehensions #1971

hogiyogi597 opened this issue Jul 28, 2020 · 3 comments · Fixed by #1972

Comments

@hogiyogi597
Copy link

It was brought up in a few Gitter posts recently that it would be nice to have a withFilter alias for filter to allow Streams to be used in for comprehensions.

https://gitter.im/functional-streams-for-scala/fs2?at=5f0f056215779f6fdca8c090
https://gitter.im/functional-streams-for-scala/fs2?at=5f207b56e90668200523130e

I am planning on adding this and using this issue to track progress.

@kubukoz
Copy link
Member

kubukoz commented Jul 28, 2020

I was convinced Scala falls back to filter if withFilter isn't defined. Has that changed recently, or is my memory failing me?

@hogiyogi597
Copy link
Author

@kubukoz It looks like it might have been removed. I am not totally familiar with it but I did find this:
scala/bug#6455

If I remove my withFilter method and try to use it in the for comprehension in my test I get this error:

[error] /Users/shogan/_Personal/scala_fp/fs2/core/shared/src/test/scala/fs2/StreamCombinatorsSuite.scala:1240:30: value withFilter is not a member of fs2.Stream[[x]fs2.Pure[x],Int]
[error]         value <- Stream.range(0, 10)
[error]                              ^
[error] one error found

@kubukoz
Copy link
Member

kubukoz commented Jul 28, 2020 via email

mpilquist added a commit that referenced this issue Jul 29, 2020
Add `withFilter` to Stream in order to filter in for comprehensions #1971
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 a pull request may close this issue.

2 participants