I have a ZIO program that looks something like this
object EUMApp extends ZIOAppDefault {
override def run: ZIO[Any & ZIOAppArgs & Scope, Any, Any] =
ZIO
.service[Some.Server]
.flatMap(_.run())
.provideSomeLayer {
AppConfig.live >>> AppEnvironment.live)
}
}
type SomeTask1 = Something1[Task]
type SomeTask2 = Something2[Task]
type SomeEnv = SomeTask1 & SomeTask2
// noinspection TypeAnnotation
val live = ZLayer.environment[SomeTask1]
++ ZLayer.environment[SomeTask2]
++ Health.SimpleService.live
++ Some.Server.live
++ Logger.live
However,I want to add a new ZLayer to live, say type SomeTask3 = Something3[Task]
So I create a new type and add it using ++ ZLayer.environment[SomeTask3]. It looks like the following
type SomeTask1 = Something1[Task]
type SomeTask2 = Something2[Task]
type SomeTask3 = Something3[Task]
type SomeEnv = SomeTask1 & SomeTask2 & SomeTask3
// noinspection TypeAnnotation
val live = ZLayer.environment[SomeTask1]
++ ZLayer.environment[SomeTask2]
++ ZLayer.environment[SomeTask3]
++ Health.SimpleService.live
++ Some.Server.live
++ Logger.live
However, when I add it, I get type mismatch error:
found : zio.ZLayer[zio.Scope with com.name.some.service.env.AppConfig with zio.Scope with com.name.some.service.env.AppConfig with zio.Scope with com.name.some.service.env.AppConfig with com.name.some.service.env.AppConfig with com.name.some.service.env.AppConfig with com.name.some.service.env.AppConfig with zio.Scope with com.name.some.service.env.AppConfig with com.name.core.web.email.client.EmailClient[zio.Task],Any,com.name.some.service.env.AppEnvironment.TenantCachedPool with com.name.some.service.env.AppEnvironment.CacheSvc with com.name.some.service.env.AppEnvironment.MailCli with com.name.some.service.env.AppEnvironment.PermissionClient with com.name.some.service.env.AppEnvironment.TenantClient with com.name.some.service.env.AppEnvironment.LaunchDarklyCli with com.name.core.db.AuthPool with com.name.core.web.HealthApi.Service[zio.UIO,com.name.core.web.HealthApi.SimpleResponse] with com.name.some.service.env.someWebService.Server with com.name.some.service.env.AppEnvironment.someSvc with Unit with Unit]
(which expands to) zio.ZLayer[zio.Scope with com.name.some.service.env.AppConfig with zio.Scope with com.name.some.service.env.AppConfig with zio.Scope with com.name.some.service.env.AppConfig with com.name.some.service.env.AppConfig with com.name.some.service.env.AppConfig with com.name.some.service.env.AppConfig with zio.Scope with com.name.some.service.env.AppConfig with com.name.core.web.email.client.EmailClient[zio.Task],Any,com.name.core.db.TenantDbPools with com.name.core.cache.Cache[zio.Task] with **com.name.core.web.email.client.EmailClient[zio.Task]** with com.name.some.service.clients.permissions.somePermissionClient[zio.Task] with com.name.some.service.clients.tenants.someTenantClient[zio.Task] with com.name.some.service.clients.launchDarkly.LaunchDarklyClient[zio.Task] with com.name.core.db.ConnPool[com.name.core.db.DbType.Auth.type,com.name.core.db.Backend.Postgres.type] with com.name.core.web.HealthApi.Service[zio.UIO,com.name.core.web.HealthApi.SimpleResponse] with com.name.some.service.env.someWebService.Server with com.name.some.service.someService[zio.Task] with Unit with Unit]
required: zio.ZLayer[com.name.some.service.env.AppConfig with Any with zio.ZIOAppArgs with zio.Scope,Any,?]
) >>> (AppEnvironment.live ++ AppEnvironment.migrateLayer))
I can't figure out how to solve this. Where does the program detect the type? Is it in Some.Server?
It looks something like this sealed trait Server extends SomeService[SomeEnv, AppConfig] {...}
I add the new type to SomeEnv but not it doesn't fix the issue