Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alexvanolst
Copy link
Contributor

Resolves #1491

Since there was an "open" question on the behaviour of head two variants were added.

head which is equivalent to take(1) and is safe for infinite streams
first which consumes the entire stream (i.e. the inverse of last)

@adamgfraser
Copy link
Contributor

Just my two cents first seems like a dangerous operation. I don't know if we should have a shortcut for it.

@alexvanolst
Copy link
Contributor Author

I wouldn't say I'm sold on it either. @iravid Since you raised the question on whether it should have that behaviour, what do you think?

@iravid
Copy link
Member

iravid commented Nov 3, 2019

Yes, I'm not sold either. Let's drop first. Anyone who figures out they need it can probably implement it manually :-)

Could you add tests for head and last?

@regiskuckaertz
Copy link
Member

It seems to me these should go into ZSink instead no?

@alexvanolst
Copy link
Contributor Author

@regiskuckaertz I don't think head makes too much sense as part of ZSink.
For last we could add it to ZSink and keep the shorthand using it.

@iravid
Copy link
Member

iravid commented Nov 3, 2019

Yeah, ZSink.head and ZSink.last would be useful. I'll add another ticket for those.

@iravid
Copy link
Member

iravid commented Nov 3, 2019

As currently implemented, head wouldn't make sense on ZSink, no. It can be implemented using run and a ZSink that keeps the first element. No need to do it in this PR though.

@alexvanolst
Copy link
Contributor Author

I've added the tests. @iravid Feel free to assign / ping me when you create that other ticket.

@iravid iravid merged commit c54c8bd into zio:master Nov 3, 2019
@alexvanolst alexvanolst deleted the 1491-shorthands-for-running-stream branch November 3, 2019 14:11
ghostdogpr pushed a commit to ghostdogpr/scalaz-zio that referenced this pull request Nov 5, 2019
* Add new shorthands for running ZStream

* Remove ZStream#first

* Add tests for ZStream head and last

* Rename ZStream head and last to runHead and runLast
Twizty pushed a commit to Twizty/zio that referenced this pull request Nov 13, 2019
* Add new shorthands for running ZStream

* Remove ZStream#first

* Add tests for ZStream head and last

* Rename ZStream head and last to runHead and runLast
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.

Add more shorthands for running streams

5 participants