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

[prelude] make Stream lazier #851

Merged
merged 5 commits into from
Nov 20, 2024
Merged

[prelude] make Stream lazier #851

merged 5 commits into from
Nov 20, 2024

Conversation

hearnadam
Copy link
Collaborator

@hearnadam hearnadam commented Nov 19, 2024

  • stop using class member, enforcing accidental eagerness
  • add new method: Stream.range to simplify creation of streams
  • init/range: accept chunkSize to limit size of Chunks- Chunk.from (Array): remove AnyRef type bound

The first PR to address #679. This change is important to ensure the laziness of streams initialized from non-effectful sources.

@hearnadam hearnadam force-pushed the lazy-stream branch 2 times, most recently from 9f4646a to 0737e59 Compare November 20, 2024 05:32
- stop using class member, enforcing accidental eagerness
- add new method: Stream.range to simplify creation of streams
- init/range: accept `chunkSize` to limit size of Chunks
- Chunk.from (Array): remove AnyRef type bound
val _chunkSize = chunkSize max 1

Emit.andMap(Chunk.empty[Int]) { ack =>
Loop(start, ack) { (current, ack) =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The contents of this loop can probably be simplified. I can take a look later.

@hearnadam hearnadam merged commit 11f2447 into getkyo:main Nov 20, 2024
3 checks passed
@hearnadam hearnadam deleted the lazy-stream branch November 20, 2024 18:39
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