8000 ZIO.serviceWith is too restrictive · Issue #5555 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ZIO.serviceWith is too restrictive #5555
Closed
@tuleism

Description

@tuleism

Currently it's implemented as:

  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] =
      new ZIO.Read(r => f(r.get))
  }

which requires that f return a ZIO[Has[Service], ...]. Why do we need that?

Let's say Service.doSomething is a function with type ZIO[Has[AnotherService], ...], then this works:

ZIO.service[Service].flatMap(_.doSomething) :: ZIO[Has[Service] with Has[AnotherService], ...]

while this doesn't:

ZIO.serviceWith[Service](_.doSomething)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0