-
Couldn't load subscription status.
- Fork 1.4k
Introduce new suspend #891
#926
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
898f033 to
3cf511d
Compare
|
@kamilkloch It's not quite enough to use the types recommended in #891. Rather, if these are primitive operations baked into the interpreter, then we need to try / catch around them as done for I recommend we motivate this by adding some tests. In particular, test that:
|
|
I am not sure if the signatures are right (with regard to the error type). Current effectSuspend(zio: => ZIO[R, E, A]): ZIO[R, E, A]is as generic as possible, but On the other hand, effectSuspend[R, A](task: => TaskR[R, A]): TaskR[R, A]does not work for current private[zio] final class Impure[E, A, B](val apply0: A => B) extends FunctionIO[E, A, B] {
val run: A => IO[E, B] = a =>
IO.suspend {
try IO.succeed[B](apply0(a))
catch {
case e: FunctionIOError[_] => IO.fail[E](e.unsafeCoerce[E])
}
}
} |
I think we can have, as you suggested, |
Thanks. Let me re-iterate to make sure I get it right. Current state in the PR: effectSuspend(zio: => ZIO[R, E, A]): ZIO[R, E, A]
effectSuspendTotal(zio: => ZIO[R, Nothing, A]): ZIO[R, Nothing, A]Desired state: effectSuspend(taskr: => TaskR[R, A]): TaskR[R, A]
effectSuspendTotal(zio: => ZIO[R, E, A]): ZIO[R, E, A]? |
|
@kamilkloch Yes, and remember the partial variations should catch Finally, remember the |
|
Only available in ZIO, RIO, Task: def effectSuspend[R, A](rio: => RIO[R, A]): RIO[R, A] |
|
@kamilkloch That looks correct to me! Don't forget the And we need tests that:
|
It's already there :)
Test for |
|
@jdegoes Do we miss anything? :) |
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 methods in ZIO, UIO, RIO, etc were sorted alphabetically recently. Can you move the new ones so that it stays sorted?
Apart from that, looks good to me.
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.
Aside from alphabetical sorting, looks good to me. Thanks for your long work on this and high attention to detail!
|
@ghostdogpr @jdegoes methods are now sorted. |
Added
suspendTotalandsuspendTotalWith, as discussed in #891. WIP.