7mind / izumi

Productivity-oriented collection of lightweight fancy stuff for Scala toolchain

Home Page:https://izumi.7mind.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Removal of Trifunctor Hierarchy

neko-kai opened this issue · comments

commented

It's impossible to implement current trifunctor hierarchy typeclasses for ZIO 2: MonadAsk, Arrow etc.
ZIO 2 changed the environment API, removing the zio.Has data type, merging it into ZIO itself and requiring : Tag constraints on all operations with the environment. This makes it impossible to implement trifunctor hierarchy methods such as def ask[R]: F[R, Nothing, R] because we don't have a Tag for R. There are three reasonable paths forward:

  1. Don't change trifunctor hierarchy, instead implement it for an opaque newtype over ZIO that uses a custom FiberRef to store the environment. This would require converting to and from this newtype to use trifunctor methods.
  2. Change the trifunctor hierarchy to specialize it completely to ZIO ZEnvironment / or a copy of such interned in BIO. These abstractions would no longer truly represent pure Arrow/Reader semantics because of ZEnvironment's Set semantics.
  3. Just delete the trifunctor hierarchy completely. We haven't found much use for it and we see no evidence of it being used elsewhere. We asked about deleting it on Izumi telegram in June and there's been no dissent. Additionally, since version 1.1.0-M24 (Update to ZIO 2) the trifunctor hierarchy has been de facto unusable - with no instances for ZIO, there were zero implementors for trifunctor typeclasses. So far, no one has noticed and filed an issue, adding evidence to the argument that it won't be missed.

So far, we're going ahead with deleting it. This issue will stay open for some time in case anyone wants to discuss this.

commented

Trifunctor hierarchy was removed in #2027