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

Pull: turn flatMapOutput into an extension method. #3016

Merged
merged 1 commit into from
Oct 16, 2022

Conversation

diesalbla
Copy link
Contributor

We may like method calls, even extension methods, better than functions. Plus, we need fewer type arguments in the calls.

@diesalbla diesalbla force-pushed the flatmapoutput_as_method branch from a26e2f1 to d67bd7c Compare October 16, 2022 15:44
@@ -962,6 +962,8 @@ final class Stream[+F[_], +O] private[fs2] (private[fs2] val underlying: Pull[F,
queue: Queue[F2, Option[Chunk[O2]]]
): Stream[F2, Nothing] = enqueueNoneTerminatedChunks(queue: QueueSink[F2, Option[Chunk[O2]]])

import Pull.StreamPullOps
Copy link
Member

Choose a reason for hiding this comment

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

Why is the import necessary, is it not in implicit scope automatically?

Copy link
Contributor Author

@diesalbla diesalbla Oct 16, 2022

Choose a reason for hiding this comment

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

Failed to compile in Scala 3 without it. It could be that Scala 3 has narrowed that scope.

Comment on lines 1291 to 1299
private[fs2] def flatMapOutput[F[_], F2[x] >: F[x], O, O2](
p: Pull[F, O, Unit],
f: O => Pull[F2, O2, Unit]
): Pull[F2, O2, Unit] =
p match {
case a: AlgEffect[F, Unit] => a
case r: Terminal[_] => r
case _ => FlatMapOutput(p, f)
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding a MiMa filter, can we just make this deprecated and delegate it to the new implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmmm if it is a private[fs2] method, how could a binary incompatibility happen?

Copy link
Member

Choose a reason for hiding this comment

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

It's because of scala/scala3#10842.

It would be safe to add a filter, but every filter we add risks accidentally masking a real issue. So my personal preference is to avoid filters even for private stuff if there's an easy fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not ideal, but so be it. Added back.

@diesalbla diesalbla force-pushed the flatmapoutput_as_method branch from d67bd7c to 45766d0 Compare October 16, 2022 16:07
We may like method calls, even extension methods, better than
functions. Plus, we need fewer type arguments in the calls.
@diesalbla diesalbla force-pushed the flatmapoutput_as_method branch from 5d5911b to d95cd67 Compare October 16, 2022 16:17
@diesalbla diesalbla merged commit 91e7079 into typelevel:main Oct 16, 2022
@diesalbla diesalbla deleted the flatmapoutput_as_method branch October 16, 2022 18:55
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