Skip to content
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

Cats' Ask and Local without ZEnvironment #685

Merged
merged 3 commits into from
Sep 22, 2023
Merged

Conversation

coffius
Copy link
Contributor

@coffius coffius commented Sep 18, 2023

No description provided.

@coffius coffius marked this pull request as ready for review September 18, 2023 17:43
@coffius
Copy link
Contributor Author

coffius commented Sep 18, 2023

It is possible to have both versions of Ask and Local by adding

  implicit def zioZEnvLocal[R, E](implicit ev: Applicative[ZIO[R, E, _]]): Local[ZIO[R, E, _], ZEnvironment[R]] =
    new Local[ZIO[R, E, _], ZEnvironment[R]] {
      override def applicative: Applicative[ZIO[R, E, _]] = ev

      override def ask[E2 >: ZEnvironment[R]]: ZIO[R, E, E2] = ZIO.environment

      override def local[A](fa: ZIO[R, E, A])(f: ZEnvironment[R] => ZEnvironment[R]): ZIO[R, E, A] =
        fa.provideSomeEnvironment(f)(InteropTracer.newTrace(f))
    }

  implicit def zioZEnvAsk[R1, R <: R1, E](implicit ev: Applicative[ZIO[R, E, _]]): Ask[ZIO[R, E, _], ZEnvironment[R1]] =
    new Ask[ZIO[R, E, _], ZEnvironment[R1]] {
      override def applicative: Applicative[ZIO[R, E, _]] = ev

      override def ask[R2 >: ZEnvironment[R1]]: ZIO[R, E, R2] = ZIO.environment
    }

@neko-kai
Copy link
Member

@coffius
Yes, we should have both. Could you please add back the old instances, placed in a low priority supertype?

@coffius
Copy link
Contributor Author

coffius commented Sep 22, 2023

@neko-kai, all fixed

@neko-kai neko-kai merged commit e196bb6 into zio:main Sep 22, 2023
19 checks passed
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.

2 participants