-
Notifications
You must be signed in to change notification settings - Fork 607
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
Refactor merge implementation #3242
Conversation
Co-authored-by: Diego E. Alonso <diesalbla@gmail.com>
Co-authored-by: Diego E. Alonso <diesalbla@gmail.com>
Co-authored-by: Diego E. Alonso <diesalbla@gmail.com>
The most recent builds failed due to failures in the following tests:
Neither of these failures are related to the |
most time-based tests can be run on the Cats Effect test runtime with fs2/core/shared/src/test/scala/fs2/StreamCombinatorsSuite.scala Lines 42 to 45 in d7f1b71
|
b168d3f
to
7df7869
Compare
7df7869
to
2c78b9f
Compare
I've used Looking at the size of the changeset, it might be worth pulling it out into a different PR - if so, let me know. |
@@ -55,7 +55,7 @@ class HashSuite extends Fs2Suite with HashSuitePlatform with TestPlatform { | |||
} | |||
|
|||
test("empty input") { | |||
Stream.empty[IO].through(sha1).compile.count.assertEquals(20L) | |||
Stream.empty.covary[IO].through(sha1).compile.count.assertEquals(20L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On adding the pretty printer implicit conversion, Stream.empty
resolved to the . I'm at a loss as to why.val empty
instead of def empty[A]
on the monoidK instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stream | ||
.empty[IO] | ||
.empty | ||
.covary[IO] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I missed #3242 (comment). Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a compile error in the build (locally too), which I'm still figuring out:
[error] /home/runner/work/fs2/fs2/io/js/src/test/scala/fs2/io/IoPlatformSuite.scala:111:13: value empty of type fs2.Stream[fs2.Pure,Nothing] does not take type parameters.
[error] .empty[IO]
[error] ^
[error] one error found
It's caused by the implicit added for the pretty printer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I know why:
Stream.empty[IO]
uses an apply
, so is desugared to Stream.empty.apply[IO]
:
The apply[F[_]]
function is added by PureOps
:
implicit final class PureOps[O](private val self: Stream[Pure, O]) extends AnyVal {
def apply[F[_]]: Stream[F, O] = covary
}
This conflicts with the apply
function in the scalacheck pretty printer.
To give some context, @djspiewak and I were looking through
merge
and found the implementation difficult to understand, then tried to rewrite it to use new cats-effect primitives.I'm not sure that the code I've settled on is actually any better than the old implementation, but think it's worth getting a second opinion on.
The main differences are:
SingallingRef
over twoDeferred
s for managing the upstream state.evalMap(guard.aquire)
instead of an explicit pull for pulling from upstream.