8000 Generalize Type Signature of ServiceWith by adamgfraser · Pull Request #5558 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Generalize Type Signature of ServiceWith #5558

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

Merged
merged 6 commits into from
Sep 18, 2021
Merged

Generalize Type Signature of ServiceWith #5558

merged 6 commits into from
Sep 18, 2021

Conversation

adamgfraser
Copy link
Contributor

Fixes #5555.

@adamgfraser adamgfraser requested a review from iravid as a code owner September 8, 2021 13:03
@@ -5427,7 +5427,7 @@ object ZIO extends ZIOCompanionPlatformSpecific {
}

final class ServiceWithPartiallyApplied[Service](private val dummy: Boolean = true) extends AnyVal {
def apply[E, A](f: Service => ZIO[Has[Service], E, A])(implicit tag: Tag[Service]): ZIO[Has[Service], E, A] =
def apply[R <: Has[Service], E, A](f: Service => ZIO[R, E, A])(implicit tag: Tag[Service]): ZIO[R with Has[Service], E, A] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work:

Suggested change
def apply[R <: Has[Service], E, A](f: Service => ZIO[R, E, A])(implicit tag: Tag[Service]): ZIO[R with Has[Service], E, A] =
def apply[R, E, A](f: Service => ZIO[R, E, A])(implicit tag: Tag[Service]): ZIO[R, E, A] =

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original formulation. 😃

The issue there is that it leads to a lot of spurious warnings about R being inferred as Any.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or to be more precise there are a couple of permutations:

    def apply[R, E, A](f: Service => ZIO[R, E, A])(implicit
      tag: Tag[Service]
    ): ZIO[R with Has[Service], E, A] =

This one leads to spurious warnings about a type being inferred as Any.

    def apply[R <: Has[Service], E, A](f: Service => ZIO[R, E, A])(implicit
      tag: Tag[Service]
    ): ZIO[R, E, A]

This one leads to numerous warnings of missing parameter type for the effectual function.

@adamgfraser adamgfraser requested a review from jdegoes September 8, 2021 20:03
@adamgfraser adamgfraser linked an issue Sep 13, 2021 that may be closed by this pull request
@jdegoes jdegoes merged commit d77cd88 into zio:series/2.x Sep 18, 2021
@adamgfraser adamgfraser deleted the 5555 branch September 19, 2021 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZIO.serviceWith is too restrictive
2 participants
0