-
Couldn't load subscription status.
- Fork 1.4k
ZIO with contextual effects #582
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
| "-Xsource:2.13", | ||
| "-Ywarn-numeric-widen", | ||
| "-Ywarn-value-discard", | ||
| "-Xfatal-warnings" |
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 are you dropping fatal warnings?
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.
There were some warnings,
thanks, I added those lines again
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 don't know how my comment disappear :D !
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.
@NeQuissimus I added this plugin:
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")|
you guys... breaking everything I've built so far and not making me feel bad about it... |
|
I asked the following question in the meetup tonight
Now thinking about using HLists instead of intersection types. |
| * arguments to the program and has to return an `IO` with the errors fully handled. | ||
| */ | ||
| def run(args: List[String]): IO[Nothing, ExitStatus] | ||
| def run(args: List[String]): ZIO[Environment, Nothing, Int] |
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 feel something like a ReturnCode that is equivalent to an unsigned byte would be clearer here than Int. Exit codes are 0 <= x <= 255.
| */ | ||
| final def repeatOrElseEither[R1 <: R, B, E2, C]( | ||
| schedule: Schedule[R1, A, B], | ||
| orElse: (E, Option[B]) => ZIO[R1 with Clock, E2, C] |
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 does R1 need the with Clock here but not in the orElse above?
I am clearly missing something :)
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.
in repeatOrElseEither we used Schedule which has Clock now
|
|
||
| implicit final val ZIOIO: ZIO[IO] = new ZIO[IO] { | ||
| final def liftZIO[E, A](io: IO[E, A]): IO[E, A] = io | ||
| trait ZIO_E_Any extends ZIO_E_Throwable { |
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 am not a fan of these strange trait names...
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'll clean them up in followup PR.
|
It would be great to provide additional documentation for the microsite. |
|
Additionally, I fear this introduces the ambiguity of when one says "zio"/"ZIO" they mean the library or the datatype in that library. I caught myself today saying "scalaz-zio's ZIO datatype" which is a mouthful. Maybe I should've said "scalaz's ZIO datatype", which is defined in the scalaz-zio foundation library. |
| } | ||
| trait Live extends Random { | ||
| val random: Service[Any] = new Service[Any] { | ||
| import scala.util.{ Random => SRandom } |
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.
Excuse my intrusion on this package given my absence in scala, but this is effectively just using a global random instance, even if it's observably pure. I'm not precisely sure that's a great thing to expose.
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 | ||
| type Task[A] = IO[Throwable, A] | ||
| type Task[A] = Task[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.
type Task[A] = Task[A]?
|
Killing it 👍 I'll give a review this weekend. |
@tabdulradi We would lose type inference and incur a severe dispatch performance penalty. What you want should be trivial in dotty when we have proper intersection types. |
|
@tabdulradi Should be possible! 💡 ZIO itself makes no requirements on environmental subtyping, but subtyping is supported if you want to use it (via auto-widening in flatMap). Also some really interesting things become possible with higher-kinded This is an area of active exploration in Scala... 🔎 |
|
There's some good feedback here. Since this has already had 3 full reviews prior to opening and several more since then, I'm going to go ahead and merge, and address minor cleanup and major documentation in followup PRs. |
|
@tabdulradi That will likely require macros. I've seen people try to construct |
| * Lifts an `IO[E, R]`` into `Managed[E, R]`` with a release action. | ||
| */ | ||
| final def make[E, R](acquire: IO[E, R])(release: R => IO[Nothing, _]): Managed[E, R] = | ||
| final def make[R, E, A](acquire: ZIO[R, E, A])(release: A => UIO[_]): Managed[R, E, 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.
Shouldn't release be a ZIO[R1, Nothing, _]? Similar to IO.bracket?
No description provided.