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

Skip to content

Conversation

@TobiasPfeifer
Copy link
Contributor

@TobiasPfeifer TobiasPfeifer commented Jun 29, 2020

@TobiasPfeifer TobiasPfeifer requested a review from iravid as a code owner June 29, 2020 17:47
@CLAassistant
Copy link

CLAassistant commented Jun 29, 2020

CLA assistant check
All committers have signed the CLA.

@TobiasPfeifer TobiasPfeifer force-pushed the feature/#3913-ZTransducer-splitOnChunk branch from 9b177a2 to 8db603a Compare June 29, 2020 17:52
@TobiasPfeifer TobiasPfeifer force-pushed the feature/#3913-ZTransducer-splitOnChunk branch from 7c836aa to be1cb10 Compare July 1, 2020 06:38
@TobiasPfeifer TobiasPfeifer force-pushed the feature/#3913-ZTransducer-splitOnChunk branch from 98323c9 to e5d80d6 Compare July 1, 2020 09:30
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

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

Hi @TobiasPfeifer, sorry for the delay here. The changes look good and the coverage is fantastic. Left one question regarding the signature.

/**
* Splits elements on a delimiter and transforms the splits into desired output.
*/
def splitOnChunk[A, O: ClassTag](delimiter: Chunk[A], fn: Chunk[A] => O): ZTransducer[Any, Nothing, A, O] =
Copy link
Member

Choose a reason for hiding this comment

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

Not sure we need fn here? That's easy enough for the user to apply with ZTransducer#map, no?

Copy link
Contributor Author

@TobiasPfeifer TobiasPfeifer Jul 16, 2020

Choose a reason for hiding this comment

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

Type signature would then be ZTransducer[Any, Nothing, A, Chunk[A]] that results in a ZStream[R, E, Chunk[Chunk[A]]]
Flattening the Chunk[Chunk[A]] would just reverse the split. So mapping the nested Chunk[A] is the only useful continuation I can think of.

Is there another useful thing to do with Chunk[Chunk[A]] than mapping it to some Chunk[O]?

ZTransducer.splitOn does string concatenation (=mapping) as well to not produce Chunk[Chunk[String]] that has to be mapped to Chunk[String]

Copy link
Member

Choose a reason for hiding this comment

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

The resulting stream would be ZStream[R, E, Chunk[A]], not Chunk[Chunk[A]] - applying flattenChunks would not reverse the split (because the delimiter is discarded) but rather provide a stream of all the individual elements.

Does that make sense?

Copy link
Contributor Author

@TobiasPfeifer TobiasPfeifer Jul 17, 2020

Choose a reason for hiding this comment

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

you are right. I was confused when working on a ZStream[R, E, Chunk[A]], but need to call flattenChunks in this case before splitting anyways.

changes applied already and added another test for consecutive delimiters

@iravid iravid merged commit 4fd54f5 into zio:master Jul 20, 2020
@iravid
Copy link
Member

iravid commented Jul 20, 2020

Thank you @TobiasPfeifer!

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.

3 participants