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

Relax queue-related signatures to use QueueSink / QueueSource #2466

Merged
merged 2 commits into from
Jul 8, 2021

Conversation

armanbilge
Copy link
Member

@armanbilge armanbilge commented Jul 5, 2021

Supersedes #2465

(GH wouldn't let me re-open the old PR)

@arosien
Copy link
Contributor

arosien commented Jul 5, 2021

Fixes #2437 I believe.

@mpilquist mpilquist merged commit ab3221d into typelevel:main Jul 8, 2021
@kubukoz
Copy link
Member

kubukoz commented Jul 12, 2021

I'm just curious... I thought type erasure would consider these identical: okay I see, Queue and QueueSource aren't generics themselves so they'll end up as Queue and QueueSource in the bytecode. Obviously 😂

def fromQueueUnterminated[F[_]: Functor, A](
queue: QueueSource[F, A],
limit: Int = Int.MaxValue
): Stream[F, A] =
fromQueueNoneTerminatedChunk_[F, A](
queue.take.map(a => Some(Chunk.singleton(a))),
queue.tryTake.map(_.map(a => Some(Chunk.singleton(a)))),
limit
)
/** Returns a stream of elements from the supplied queue.
*
* All elements that are available, up to the specified limit,
* are dequeued and emitted as a single chunk.
*/
def fromQueueUnterminated[F[_]: Functor, A](
queue: Queue[F, A],
limit: Int
): Stream[F, A] = fromQueueUnterminated(queue: QueueSource[F, A], limit)

(also, shouldn't the second one be private[fs2]?)

@armanbilge
Copy link
Member Author

armanbilge commented Jul 12, 2021

@kubukoz I would have liked to, but marking it as private[fs2] still disappears the static forwarders :(

In fact, this was the problem in the original PR #2465.

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.

6 participants