-
Couldn't load subscription status.
- Fork 1.4k
ZTransducer should provide a way to split on Chunk[A] #3913 #3914
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
ZTransducer should provide a way to split on Chunk[A] #3913 #3914
Conversation
9b177a2 to
8db603a
Compare
7c836aa to
be1cb10
Compare
98323c9 to
e5d80d6
Compare
There was a problem hiding this 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] = |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
Thank you @TobiasPfeifer! |
#3913