-
Couldn't load subscription status.
- Fork 1.4k
Add ZSink.foldWeightedDecompose/M and fix leftover handling in transduce #1675
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
Conversation
| ): ZSink[Any, Nothing, A, A, S] = | ||
| new SinkPure[Nothing, A, A, S] { | ||
| type State = (S, Long, Boolean, Chunk[A]) | ||
| import internal.FoldWeightedState |
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.
Since we are starting to use ZSink.internal for complex states, it makes sense to restrict the old imports to only the needed types. Just a mental note.
| * of type `S`, until `max` worth of elements (determined by the `costFn`) | ||
| * have been folded. | ||
| * | ||
| * @note In case |
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.
Missing scaladoc? Same with foldWeighted.
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.
Oops, yes.
| * of type `S`, until `max` worth of elements (determined by the `costFn`) have | ||
| * been folded. | ||
| */ | ||
| final def foldWeightedDecomposeM[R, R1 <: R, E, E1 >: E, A, S]( |
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.
We should document the decompose function better.
| */ | ||
| final def foldWeightedDecompose[A, S]( | ||
| z: S | ||
| )(costFn: A => Long, max: Long, decompose: A => Chunk[A] = Chunk.single[A](_))( |
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.
Scala 2.11 has trouble with this line.
|
Minor documentation comments. Have a written approval. 😄 |
| init <- sink.initial.toManaged_ | ||
| sinkStateRef <- Ref.make[(sink.State, Boolean)]((init, false)).toManaged_ | ||
| done <- Ref.make(false).toManaged_ | ||
| sink <- managedSink.map(_.mapError(Some(_))) |
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.
Nice.
…uce (zio#1675) * Add ZSink.foldWeightedDecompose/M and fix leftover handling in transduce * 2.11 fixes * Improve docs
Resolves: #1671
Resolves: #1673
@vasilmkd could you have a look?