ZIO, fs2 and other libraries found out that a natural encoding in Scala relies on multiple type parameters with variance (I believe John called this effect rotation):
- ZIO[-R, +E, +A]
- fs2.Stream[F[_], +A]
- Optic[+E, -S, +T, +A, -B] or even more type parameters if include index optics
With this encoding, we can express the absence of error (E = Nothing), absence of effect (F = Nothing), absence of environment variables (R = Any) and all this with perfect type inference. So it is a big win on all fronts except for function signatures and error messages. As we can end-up with an Optic[Nothing, User, User, String, String] instead of Lens[User, String] or