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 unconsNonEmpty combinator to Pull #1527

Closed
Daenyth opened this issue Jun 28, 2019 · 1 comment
Closed

Add unconsNonEmpty combinator to Pull #1527

Daenyth opened this issue Jun 28, 2019 · 1 comment

Comments

@Daenyth
Copy link
Contributor

Daenyth commented Jun 28, 2019

It's often useful to write pull with uncons, and skip over empty chunks by pulling the next chunk. This combinator makes sense to be in the library

example impl from @mpilquist: https://gitter.im/functional-streams-for-scala/fs2?at=5d162e628dff05627b84bebe

    def unconsNonEmpty: Pull[F, INothing, Option[(Chunk[O], Stream[F, O])]] =
      self.uncons.flatMap {
        case Some((hd, tl)) =>
          if (hd.isEmpty) tl.pull.unconsNonEmpty
          else Pull.pure(Some((hd, tl)))
        case None => Pull.pure(None)
      }
@monadplus
Copy link
Contributor

I was wondering in which use cases you will be pulling empty chunks 🤔

valydia pushed a commit to valydia/fs2 that referenced this issue Oct 3, 2019
mpilquist added a commit that referenced this issue Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants