Comments (9)
@larousso The errors are already accumulated in Cause[E]
for ZIO. Could you please check if
(io1, io2).parTupled.mapErrorCause {
c => Cause.fail(NonEmptyList.fromListUnsafe(c.failures).reduce)
}
contains all the errors you're looking for?
from interop-cats.
Yes, this is working :
testM("zio") {
import cats.implicits._
import zio.interop.catz._
assertM(
(ZIO.fail(NonEmptyList.one("Error1")), ZIO.fail(NonEmptyList.one("Error2"))).parTupled.mapErrorCause { c =>
Cause.fail(NonEmptyList.fromListUnsafe(c.failures).reduce)
}.either,
isLeft(
equalTo(NonEmptyList.of("Error1", "Error2"))
)
)
}
from interop-cats.
@larousso In that case I think this issue can be closed? I feel like there wouldn't be much gain from a new Parallel
instance with E: Semigroup
constraint since Cause
already does the accumulation here....
from interop-cats.
I really prefer the concise syntax with just
(io1, io2).parTupled
instead of
(io1, io2).parTupled.mapErrorCause {
c => Cause.fail(NonEmptyList.fromListUnsafe(c.failures).reduce)
}
but I understand that it's not fine for you to add a new instance with a E as a monoid so I can close the issue.
from interop-cats.
@larousso you can add it and there's a precedent with MonoidK/SemigroupK instances - https://github.com/zio/interop-cats/blob/master/interop-cats/shared/src/main/scala/zio/interop/cats.scala#L109 - but then I'm not sure how intuitive it would be to change the error behavior based on existence/nonexistence of instances for error (the same applies to the SemigroupK instance)
from interop-cats.
It seams to be the standard behavior for cats.
For exemple:
testM("cats") {
import cats._
import cats.data._
import cats.implicits._
import zio.interop.catz._
val et1 = EitherT.leftT[Task, String](NonEmptyList.one("Error1"))
val et2 = EitherT.leftT[Task, String](NonEmptyList.one("Error2"))
assertM(
(et1, et2).parTupled.value,
isLeft(
equalTo(NonEmptyList.of("Error1", "Error2"))
)
)
}
from interop-cats.
@larousso The difference is that you must specifically wrap your IO in EitherT
to enable this behavior. There's no low-priority instance for Parallel[EitherT[...]] that doesn't require a Semigroup instance – therefore your errors will either be accumulated or your compilation will fail, there won't be a silent change of behavior towards non-accumulation from a missing instance.
from interop-cats.
For ZIO there's a silent change of behavior in SemigroupK
currently. I'm not super fond of that as is, with a conditional Parallel
instance there will be more silent changes of behavior...
/cc @zio/core for opinions...
from interop-cats.
ZIO cannot guarantee parallel error accumulation. This is because when one running effect fails, the others are canceled immediately... possibly before they begin.
You could do:
ZIO.uninterruptible {
...
}
If you wanted to "force" non-cancellation. That should allow you to get parallel error accumulation.
from interop-cats.
Related Issues (20)
- Canceler unlawfully ignored in CE3 `Async#async` implementation, can cause hangs etc. HOT 4
- Docs are gone HOT 3
- No info in ecosystem
- `MonadCancel#uncancelable` disrepancies
- CE2+ZIO2.0 interop needed HOT 2
- Please don't use the version field to differentiate parallel artifacts HOT 6
- Intermittent `runtime exists with cause Traced(...)` errors.
- CE and fs2 versions are out of date HOT 8
- Support the "onCancel associates over uncancelable boundary" law (ZIO 2/CE 3) HOT 1
- Dependency on `zio.clock` package HOT 2
- Http4s Client leaks with ZIO 2.x HOT 3
- `ZioMonadError.whenA` calls by-name argument `f: => F[A]` several times even when `cond` is false
- Upgrade zio version to latest. HOT 3
- Suspect publish of `23.0.0.3` HOT 3
- Ask and Local instances for FiberRef
- Graceful shutdown of http4s-ember-server with ZIO hanging HOT 3
- Add implicit fs2.io.net.Network instance HOT 1
- NoClassDefFoundError with Scala 2.x when cats-core isn't imported directly
- Add ScalaNative crossbuilding
- Memory leaks while using fs2-kafka consumer HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interop-cats.