8000 Implement ZSink#filterInput and filterInputM by jupposessho · Pull Request #4979 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implement ZSink#filterInput and filterInputM #4979

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

Merged
merged 1 commit into from
Apr 19, 2021
Merged

Implement ZSink#filterInput and filterInputM #4979

merged 1 commit into from
Apr 19, 2021

Conversation

jupposessho
Copy link
Contributor
@jupposessho jupposessho commented Apr 19, 2021

Part of #4886

@jupposessho jupposessho requested a review from iravid as a code owner April 19, 2021 14:12
@@ -154,6 +154,28 @@ class ZSink[-R, -InErr, -In, +OutErr, +L, +Z](val channel: ZChannel[R, InErr, Ch
): ZSink[R1, InErr1, In1, OutErr1, L, Z1] =
contramapChunksM(f).mapM(g)

def filterInput[In1 <: In](p: In1 => Boolean): ZSink[R, InErr, In1, OutErr, L, Z] = {
lazy val loop: ZChannel[R, InErr, Chunk[In1], Any, InErr, Chunk[In], Any] =
ZChannel.readWith[R, InErr, Chunk[In1], Any, InErr, Chunk[In], Any](
Copy link
Member

Choose a reason for hiding this comment

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

These can be simplified to contramap(_.filter(p )) :-) (same for filterInputM)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost had it but found foldChunks first and tried with that but it was not good for this :)
Thanks!

@jupposessho jupposessho requested a review from iravid April 19, 2021 19:46
@iravid iravid merged commit 4b11e10 into zio:series/2.x Apr 19, 2021
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.

2 participants
0