-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Moved to fork] ZIO module for interoperability with related libraries #42
Conversation
Seems like a good idea. 👍 |
|
||
import scala.concurrent.Future | ||
|
||
object future { |
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.
Hey @jdegoes I could you a bit of early feedback on the API while I work on the impl + tests
|
||
val duHastMich: IO[Void, Future[Int]] = duHast.toFuture | ||
|
||
val duHastMichGefragt: Future[Int] = unsafePerformIO(duHastMich) |
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.
RAMMSTEIN!!!!!!
|
||
import cats.effect.IO | ||
|
||
object catz { |
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.
Hopefully this can be mostly grabbed from ioeffect
.
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.
Yeah, i'll port it from there. And try to fix a bug that prevents sz IO to be used in fs2 😞
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.
What bug is this?
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, I have to reproduce what fs2 is doing with the Effect
instance. Stream.join
works with cats IO
and monix Task
but hangs with ioeffect IO
.
|
||
} | ||
|
||
object SampleUsage { |
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.
These examples should be moved, but I'm not sure where.
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.
Sure 😄 It's only to demo the proposed API. I'll add this to the tests and then write some nice examples in the docs
|
||
object future { | ||
|
||
implicit class IOObjOps(private val ioObj: IO.type) extends AnyVal { |
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 like this, if Scala doesn't have a problem with it. Would like to use the same technique in Scalaz 8 to support \/
, Maybe
.
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.
It doesn't (have a problem). That's the idea of the eager demo, to show that all this compiles and feels super ergonomic IMO.
object future { | ||
|
||
implicit class IOObjOps(private val ioObj: IO.type) extends AnyVal { | ||
def fromFuture[A](ftr: () => Future[A]): IO[Throwable, 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.
Why not by-name?
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.
Dunno, I don't like it since last time it kept me several nights debugging RTS
} | ||
|
||
implicit class IOOps[E, A](private val io: IO[E, A]) extends AnyVal { | ||
def toFuture(f: E => Throwable): IO[Void, Future[A]] = io.leftMap(f).toFuture |
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 think it should have a different name than the toFuture
defined in IOThrowableOps
. Maybe toFutureE
.
Also, it would be customary to make this polymorphic in E2
, rather than fixing to Void
, although they are of course equivalent.
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.
Noted. I agree.
} | ||
|
||
implicit class IOThrowableOps[A](private val io: IO[Throwable, A]) extends AnyVal { | ||
def toFuture: IO[Void, Future[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.
It would be customary to make this polymorphic in E
, rather than fixing to Void
, although they are of course equivalent.
|
||
import scala.concurrent.Future | ||
|
||
object future { |
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.
Should this be a package object?
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.
What would be the benefit? Just asking.
case Success(a) => cb(ExitResult.Completed(a)) | ||
case Failure(t) => cb(ExitResult.Failed(t)) | ||
} | ||
} | ||
} |
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.
Do you want to thunk the Future
in this case? on ioeffect
I just pushed this PR in - i like the idea of having IO[Void, Future[A]]
- then you can lift via point
or now
.
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 saw it, I commented precisely saying i don't like that 🙂
* convert into multi-project build * move some settings to shared
* Backport latest changes from Z8 It includes changes from the following commits affecting the module `effect` in the scalaz/scalaz repository: - scalaz/scalaz@cf6ae80e3 fix bug in par and general code cleanup - scalaz/scalaz@2f6c3dcae code cleanup - scalaz/scalaz@a38e2b634 scalafmt - scalaz/scalaz@d07918ba5 wrap up error model refactoring & update tests - scalaz/scalaz@37c3e92a2 improved docs, function names, and bug fixes - scalaz/scalaz@43e5f0a00 fixes #1665 * fixup! Backport latest changes from Z8
* version bumps * use the same formatting as scalaz8 * fixup! use the same formatting as scalaz8
Include changes from following commits: - scalaz/scalaz@c2f7e6dd8 Add Liskov for `IO.widen` - scalaz/scalaz@3242958cf Use method value. - scalaz/scalaz@456d5ba98 Do not use case classes for IO adt, since the feature is not used. - scalaz/scalaz@043686dcd RTS: use eq/ne when comparing with null. - scalaz/scalaz@de79b92fc RTS Stack: avoid array copy via nesting. removed unused peek(). - scalaz/scalaz@d9ce85e72 remove unused import - scalaz/scalaz@0813ee457 remove try modify variants and add compareAndSet to IORef - scalaz/scalaz@89e337fed code cleanup - scalaz/scalaz@33ec2a23a scalafmt - scalaz/scalaz@01ef0ce21 fix bug
scalaz/scalaz@0358c41bd Modify `SafeApp#run` to return `IO[Void, ExitStatus]` scalaz/scalaz@42e7604dd Include scheduler in app shutdown
Closing to reopening it from a branch in my fork #58. If the PR is from a branch in the source repo it publishes snapshots on every push. |
-- Work In Progress --
The idea of this module is to enable code using ZIO
IO
to interact with other effect types from the Scala ecosystem such asFuture
andIO
fromcats-effect
. Also define instances for TCs fromscalaz-7.2
interop
sbt moduleFuture
conversionsIO
IO