-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Added zipWithPar and derived zipPar, zipParLeft and zipParRight #1029
Conversation
@neko-kai I know you have mentioned possibly adding a I have 2 commits:
Please let me know your thoughts on this |
def zipWithPar[R, E, A, R1 <: R, E1 >: E, B, C](fa: F[R, E, A], fb: F[R1, E1, B])(f: (A, B) => C): F[R1, E1, C] | ||
|
||
// defaults | ||
def parTraverse_[R, E, A, B](l: Iterable[A])(f: A => F[R, E, B]): F[R, E, Unit] = InnerF.void(parTraverse(l)(f)) |
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.
I have noticed that parTraverse_
is not final
. Should this be made final
? If not, why?
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.
@Adriani277
This shouldn't be made final
because BIOAsyncZio
instance overrides it to use ZIO.foreachPar_
. This lets it use a native implementation from the effect type that is more optimized and may have enhancements compared to a naive implementation (like, better support for stack-traces, e.g. notice the new ZipLeftFn
wrapper in implementation of ZIO.<*
- https://github.com/zio/zio/blob/master/core/shared/src/main/scala/zio/ZIO.scala#L108 - this allows the stacktrace where <*
occurs to point to the source code line contained inside the user-provided that
lambda, instead of the line in ZIO.scala source file that would be there without the new ZipLeftFn
)
Generally, the only methods that are final in the hierarchy are those that are trivial enough they can't have better native implementations in the effect type. So, I'd propose to un-final zipParLeft
& zipParRight
and redirect them to <&
and &>
in BIOAsyncZio
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.
I see, thanks for the explanation.
Will make the changes
@Adriani277 Also, the izumi/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOCatsConversions.scala Line 55 in 111390e
|
I can have a look at adding the parallel conversion next. |
@Adriani277
This is for bifunctor BIOSyntax, you'll also need to repeat the same steps for trifunctor You'll also need to rename izumi/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/package.scala Line 74 in 111390e
|
@neko-kai awesome. Will have a go at adding it |
closes #1028