Skip to content

Conversation

@diesalbla
Copy link
Contributor

  • Pull - Add an uncons extension method for closed Pulls (unit)
  • Stream - Avoid "newStream" use streamNoScope
  • Avoid the ".pull" method, use the new ".uncons" method on Pull-Unit

@diesalbla diesalbla changed the title Pullstreamops Replace "ToPull" operations with "Pull.uncons" Jan 5, 2023
@mpilquist
Copy link
Member

Thoughts:

  • Moving Pull.uncons to Pull#uncons looks good, as does the optimization of the implementation.
  • I'm neutral on changing new Stream(p) to p.streamNoScope.
  • I don't like rewriting the internal recursive combinators to use Pull over Stream. The implementations use private APIs that users don't have access to, making it harder to learn from examples.

@diesalbla
Copy link
Contributor Author

I don't like rewriting the internal recursive combinators to use Pull over Stream. The implementations use private APIs that users don't have access to, making it harder to learn from examples.

We can always publish those APIs, if they are useful enough.

@diesalbla diesalbla closed this Jan 5, 2023
@diesalbla diesalbla reopened this Jan 5, 2023
@mpilquist
Copy link
Member

I don't know if that's a good idea. Seems like a lot of churn API-wise (all the recursive pulls that would need to change to use a pull instead of stream argument). What's the benefit we get for that churn?

@diesalbla
Copy link
Contributor Author

I don't know if that's a good idea. Seems like a lot of churn API-wise (all the recursive pulls that would need to change to use a pull instead of stream argument). What's the benefit we get for that churn?

Perhaps reducing the need for a second type wrapper, ToPull, in addition to the default Pull, but that may not be worth too many changes. Nevertheless, I will split this PR in twine later today.

@diesalbla diesalbla force-pushed the pullstreamops branch 2 times, most recently from a3a4ce2 to 7eb73d5 Compare January 5, 2023 19:35
@SystemFw
Copy link
Collaborator

SystemFw commented Jan 6, 2023

the .uncons extension is nice :)
I'm a slight -1 on using streamNoScope over new Stream: it forces all readers to having to think about what a scope is, which arguably isn't necessary until much later on in their journey

@diesalbla
Copy link
Contributor Author

diesalbla commented Jan 6, 2023

I'm a slight -1 on using streamNoScope over new Stream: it forces all readers to having to think about what a scope is, which arguably isn't necessary until much later on in their journey

Perhaps we should rename them as stream and scopedStream, giving the more complex notion the longer name.

Edit or maybe, add a scoped method to the unit-pull, and make def stream just add the stream wrapper, so that

  • Current .stream becomes .scoped.stream
  • Current .streamNoScope becomes .stream.

@mpilquist
Copy link
Member

mpilquist commented Jan 7, 2023 via email

@armanbilge
Copy link
Member

I thought that introducing a scope is safer, and should be the default? At least that's the feeling I get from the scaladocs. In fact I feel like streamNoScope is the more complex notion, since I have to know when it's safe to not introduce a scope.

* Only use this if you know a scope is not needed. Scope introduction is
*
* generally harmless and the risk of not introducing a scope is a memory leak
* in streams that otherwise would execute in constant memory.

@mpilquist mpilquist merged commit 363aaf0 into typelevel:main Jan 13, 2023
@diesalbla diesalbla deleted the pullstreamops branch July 27, 2023 21:29
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.

4 participants